I'm printing some fancy UTF-8 characters, i.e. right arrow 0x2192 and lightning 0x21AF, to a QTextEdit. This works great on a modern operating system like Ubuntu but fails for e.g. Windows XP, since the fonts don't seem to support those UTF-8 characters. Instead, the infamous little placeholder-squares are drawn.
Is there a way to find out, whether the current font of a QFont instance supports a given character, so I can fall back to simpler characters like "-->" for the right arrow?
I've discovered that Qt 4.8 has a QRawFont class, that indeed has a QRawFont::supportsCharacter() method that does exactly what I want, but I can't use 4.8 right now, I'm on 4.6 or 4.7 at best. I've looked at the implementation, and they call QFontEngine::canRender(). However, QFontEngine seems to be a class not accessible from the outside. The only similar sounding classes I can find in 4.7 are QFontEngineInfo and QFontEnginePlugin, both don't seem to provide anything helpful in my case.
canRender
is also called by QFontMetrics::inFont(QChar)
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With