Difficulty Rendering Bangla Text in Matplotlib

39 Views Asked by At

I'm encountering issues while attempting to print Bangla text in Matplotlib. Despite trying various methods, I've been unable to resolve the problem. Here's the code snippet I'm using, tried to print some bangla words in plot to show the bangla text rendering problem :

import pandas as pd
import matplotlib.pyplot as plt
from matplotlib.font_manager import FontProperties
from matplotlib import font_manager as fm

bangla_font_path = "/content/drive/MyDrive/SolaimanLipi_20-04-07.ttf"
font = fm.findSystemFonts(fontpaths=bangla_font_path)

text_list = ["পেরু", "রুদ্র", "ক্ষতি", "যুক্তবর্ণ", "পৃথিবী"]

plt.figure(figsize=(5, 5))

for i, text in enumerate(text_list):
    plt.text(0.5, 0.5 - i * 0.1, text, ha='center', va='center', fontproperties=FontProperties(fname=bangla_font_path))
plt.xlim(0, 1)
plt.ylim(0, 1)
plt.axis('off')
plt.show()

The output is getting like this... not as expected

I'm seeking assistance in resolving this issue so that Bangla text can be rendered correctly in Matplotlib. Thank you for your help.

0

There are 0 best solutions below