Combining diacritics sometimes cut off using Pango
Posted: 2016-05-04T16:39:05-07:00
It looks like the bounding rectangle for text sometimes isn't quite large enough to accommodate certain combining diacritics.
convert -pointsize 100 -font Mangal pango:"बहुत चुकी" example.png
You'll see that in the first word, there's a combining diacritic that gets a few pixels shaved off the bottom, while in the second word, that combining mark is placed higher and remains intact.
I'm not sure if this is really a bug in ImageMagick, or just a limitation of the Pango integration, but I've seen this problem on Windows and Linux, in IM6 and IM7, in Arabic, Thai, and Hindi, using Arial, Tahoma, and Mangal, respectively. Technically, in Unicode, you can just stack combining diacritics over & over to levels never actually used in any language, so a reasonable cutoff for the bounding rectangle is still probably desirable--the current one is just a little small for normal words in these languages.
There is also an easy workaround. If you insert a blank line before & after the text you render, all diacritics are displayed intact. I'm certainly happy doing that if that's the only way to prevent this issue.
convert -pointsize 100 -font Mangal pango:"बहुत चुकी" example.png
You'll see that in the first word, there's a combining diacritic that gets a few pixels shaved off the bottom, while in the second word, that combining mark is placed higher and remains intact.
I'm not sure if this is really a bug in ImageMagick, or just a limitation of the Pango integration, but I've seen this problem on Windows and Linux, in IM6 and IM7, in Arabic, Thai, and Hindi, using Arial, Tahoma, and Mangal, respectively. Technically, in Unicode, you can just stack combining diacritics over & over to levels never actually used in any language, so a reasonable cutoff for the bounding rectangle is still probably desirable--the current one is just a little small for normal words in these languages.
There is also an easy workaround. If you insert a blank line before & after the text you render, all diacritics are displayed intact. I'm certainly happy doing that if that's the only way to prevent this issue.