matplotlib/mplcairo

Devanagari script rendering incorrectly

nialldeacon opened this issue · 1 comments

Hi, I've been trying to use mplcairo so I can produce text in Devanagari script. This is due to the normal matplotlib backend not rendering some combined letters correctly. I've tried using both mplcairo.macosx and mplcairo.qt but in both cases the text renders the same as the default matplotlib renderer. This is likely an issue on my side rather than a bug in the code but I'm at my wit's end trying to solve this

{'python': '3.10.13 (main, Sep 11 2023, 08:39:02) [Clang 14.0.6 ]', 'mplcairo': '0.5', 'matplotlib': '3.8.2', 'cairo': '1.16.0', 'freetype': '2.12.1', 'pybind11': '2.10.0', 'raqm': None, 'hb': None}

Example code
`import mplcairo
import matplotlib
matplotlib.use("module://mplcairo.qt")
import matplotlib.pyplot as plt

plt.rcParams['font.family']='Devanagari MT'
plt.figure()
plt.plot([0,1],[0,1])

plt.title(r"विद्युतचुंबकीय विकिरण")
plt.savefig("test.pdf")`

Running on M2 Macbook Air

Output
test.pdf

I found the issue, my python via anaconda wasn't playing nicely with libraqm from homebrew.

I deactivated conda, uninstalled mplcairo, used the homebrew version of python 3.10, installed mplcairo via pip3 install git+https://github.com/matplotlib/mplcairo and reran mplcaito.get_options which resulted in
{'cairo_circles': True, 'collection_threads': 0, 'float_surface': False, 'miter_limit': 10.0, 'raqm': True, '_debug': False}

I then reran my plotting code and it gives the expected output.