-
-
Notifications
You must be signed in to change notification settings - Fork 7.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug]: Font rendering bug for Devanagari text #23082
Comments
I'm going to start by apologizing that I know nothing more about Devanagari rendering than this issue and a very quick skimming of it's wikipedia entry. It looks like the matras is a vowel diacritic that combines with the letter to its left, where as the other vowels appear below or to the right (ref https://en.wikipedia.org/wiki/Devanagari#Vowel_diacritics). Do these render correctly or are all vowels broken? I am not sure off the top of my head if we are doing the detailed text layout here or freetype is, but it is clear that the diacritic is not being handled correctly. A couple questions:
|
One more detail: we are rendering the text in the order it comes in in the string:
|
Hi Thomas, No apology necessary, thank you for looking into this issue. :) Your understanding is correct. All other vowels are fine.
The consonant-consonant ligatures "work" in the sense that they are not wrong, but not ideal. The Devanagari script has special ligatures for each pair of consonant-ligatures, but there is also a generic way to write them by adding the "halanth" diacritic ( |
Looking at the last example , it looks like the shaping on Unfortunately, I do not think this is going to be an easy fix (it is possible that we are clipping something to be positive that should be negative to move the diacritic to the left), but I suspect that our text system is not currently up to this. |
Hi Thomas, You're right, the I do need to produce graphs with (correct) Devanagari labels on them. Do you have recommendations on how to proceed? |
Unless I am mistaken, this is basically a duplicate of #8765. |
The fastest thing is probably to use import matplotlib
matplotlib.use('module://mplcairo.qt')
matplotlib.rc('font', family='Noto Sans Devanagari') # I already had NoTo installed
import matplotlib.pyplot as plt
plt.title('किसान') I am not sure how hard it would be to get mplcairo to play nice with inline, but if you need to save the output you are good to go! If you definitly need images in a notebook, I think the way to go is |
Bug summary
When rendered as part of a graph's axis label or title, Devanagari text renders incorrectly: the "matras" get affixed to the wrong letters (see the attached image, and note the difference between the string literal in the code and the rendered text in the title of the graph).
Code for reproduction
Actual outcome
Expected outcome
The rendered word should look the same as in the string literal in the code.
Additional information
No response
Operating system
macOS
Matplotlib Version
3.4.1
Matplotlib Backend
module://ipykernel.pylab.backend_inline
Python version
Python 3.9.12
Jupyter version
6.3.0
Installation
pip
The text was updated successfully, but these errors were encountered: