2

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

  • So what's the problem? Do you want to plot the image in python? – RJ Adriaansen Jan 31 '21 at 13:09
  • @RJAdriaansen i want to plot bangla text in a image. But when i do it, bangla font broken. If Click https://i.stack.imgur.com/PrHVX.png you can see what is the problem is. Thank you. – Nazmul Hasan Feb 01 '21 at 04:27
  • How exactly is the font broken? I can't read Bangla, so all I can see is a wordcloud that does use a Bangla font. – RJ Adriaansen Feb 01 '21 at 07:49
  • @RJAdriaansen For example, the original word is ভালো but it show like ভাল ো. which is broken. That is the problem happen. Thank you. – Nazmul Hasan Feb 03 '21 at 05:54
  • @NazmulHasan, did you find any solution? I have faced the same problem. I don't know what to do... – asif abdullah Oct 18 '21 at 09:50
  • @asifabdullah, Still I am facing this problem. – Nazmul Hasan Oct 21 '21 at 03:00
  • @NazmulHasan, Now I am using an image with Bangla text and placing that image in that pdf file. That's the only solution that comes to my mind. Though my texts are static, they can't be applied to the dynamic text. – asif abdullah Oct 21 '21 at 03:16

0 Answers0