Unsolved Numbers not getting rendered
-
Hi,
I have a text rendering application that converts text to images. We support multiple languages and usually do not have any issues with rendering but recently we saw a weird issue where if we used a Noto Sans Thai font, normal numbers got rendered as square tofu boxes
The first character of this string is the number 1
With the same text and same font, if I remove the thai part, it get correctly rendered.
Also if I add some text after the number then it renders correctly as well
The code I'm using is
const QSize& imgSize = QSize(1080, 1080); QImage image(imgSize, QImage::Format_ARGB32_Premultiplied); image.fill(qRgba(0, 0, 0, 0)); // Make background transparent. QPainter painter(&image); painter.setPen(QPen(fontColor)); QFont textFont( QString("Noto Sans Thai"), fontSize, QFont::Normal, false // Not using italics. ); painter.setFont(textFont); painter.drawText( 0, 0, imgSize.width(), imgSize.height(), Qt::AlignLeft, text);
I have other Noto Sans fonts installed on my machine as well that should be used as a fallback if the number is not present in Noto Sans Thai. For the same request if I change the Font to just "Noto Sans" it works correctly in all cases.
My guess is that due to some reason the correct font is not being chosen for the digit characters. How can I debug this issue? Is there any way to find out which font is used to render the text, not the entire string but just single character.
Any help on this will be greatly appreciated!
-
Hi and welcome to devnet,
Are you sure that the font is correctly found ?
-
Yes it is rendering everything correctly if I add an english letter next to the number. But if I remove that character the number does not get rendered, everything else is still fine. And I have only 1 thai supporting font and thai characters are getting rendered correctly. All my fonts are in the same place: /usr/share/fonts/
-
Can you provide a minimal compilable example including the font ?