[Interest] Fallback fonts embedded for a QtQuick application?

Tony Rietwyk tony at rightsoft.com.au
Sun Apr 20 09:28:05 CEST 2014


Hi Preet, 

> Sent: Sunday, 20 April 2014 4:20 PM
> 
> Say I have an application that has a bunch of international unicode text I
need
> to display with QtQuick. I don't necessarily know what the text is going
to be
> in advance but I do have a list of fonts where I'm fairly sure at least
one of
> them has the correct glyphs.
> 
> Is there a way to specify a list of fallback fonts to use?
> 
> I also specifically want Qt to only look at fonts I package with my
application
> (using QRC).

I don't think you can force Qt to fallback only to QRC fonts - for starters
how would Qt know which paths in your resources have the fonts?

But, you could also store a list of the fonts, and their character ranges.
When you load the texts, check each character is in one of the ranges, then
load the font using QFontDatabase.addApplicationFont.  If a previously
loaded font is no longer required, then removeApplicationFont to conserve
memory. 

Hope that helps, 

Tony





More information about the Interest mailing list