Qt: unable to load TTF file

I have a built-in Qt application that I am developing in OpenSuse 11.4 where I need to download a TTF font file. However, when I call the int QFontDatabase::addApplicationFont() function int QFontDatabase::addApplicationFont() , it returns -1 .

After reading the documentation, I found out that adding application fonts on Unix / X11 platforms without fontconfig is currently not supported.

I checked through YaST if I have a font config and it is installed - but I do not think that this is due to the fact that I use the qt-built-in library. I think I should have a built-in library with fontconfig support, but how do I do this?

Does fontconfig support qt-embedded? Can someone tell me what is going on?

+7
source share
1 answer

You can use QPA or Qt Platform Abstraction (formerly known as Lighthouse ). You need to create an implementation (can be done as a plugin or just be used directly) QPlatformIntegration , which provides a custom QPlatformFontDatabase. The trick here is to reuse most of the existing Qt implementation of QFontconfigDatabase (which is like a subclass of QBasicUnixFontDatabase).

This is exactly the method we use for PhantomJS to make it work silently (without X11) on Linux, still using Fontconfig (and therefore FreeType ) to render the text.

Unfortunately, I think Qt 4.5 is too old to run Lighthouse. Either go to 4.8, which officially supports QPA, or try to back up Lighthouse.

+5
source

All Articles