How to solve Bangla font problem in python image show?

581 Views Asked by At

When i am creating bangla word cloud, I am facing bangla font problem. Problem details and code are show below. please help me out from this problem.

from os import path
import numpy as np
from PIL import Image
from wordcloud import WordCloud, STOPWORDS
from bnlp.corpus import stopwords
import bangla
import unicodedata
file = open("Dataset/banglaText.txt", "r", encoding='UTF-8')
text = file.read()
#print(text)

# create numpy araay for wordcloud mask image
mask = np.array(Image.open(path.join("cloud.png")))
# create set of stopwords
stopwords = set(stopwords())
#custome unicode
rgx = r"[\u0980-\u09FF]+"
#create wordcloud object
wc = WordCloud(background_color="white",
               mask=mask,
               stopwords = stopwords,
               font_path="font/balooda.ttf",
               regexp=rgx
           )
# generate wordcloud
wc.generate(text)
# save to wordcloud image
result = wc.to_file(path.join("wordCloudBangla.png"))

Font break in image show

0

There are 0 best solutions below