Mixed multiple persian(farsi) and english text in matplotlib?

Viewed 983

I want to use persian fonts in matplotlib but when text is mixed like فایل pdf english text show as some square. My code in the following:

import seaborn as sns; sns.set()
import matplotlib.pyplot as plt
from bidi.algorithm import get_display
import arabic_reshaper

from matplotlib import font_manager as fm, rcParams
import os

fpath = os.path.join(rcParams["datapath"],"C:\\Users\\Ahmad\\Desktop\\Report_Examples\\BNazanin.ttf")

prop = fm.FontProperties(fname=fpath)



def make_farsi_text(x):
    reshaped_text = arabic_reshaper.reshape(x)
    farsi_text = get_display(reshaped_text)
    return farsi_text

fmri = sns.load_dataset("fmri")
ax = sns.lineplot(x="timepoint", y="signal", data=fmri)
ax.set_xlabel(make_farsi_text('فایل pdf'),fontproperties=prop)
plt.show()

Result image

1 Answers

I use another font and my problem solved. I use XB Niloofar font. You can download it from following link:

XB Niloofar download link

Related