missing font family
-
warnning: qt.qpa.fonts: Populating font family aliases took 215 ms. Replace uses of missing font family "DIN-Medium" with one that exists to avoid this cost.
then, i do this:
int font_id = QFontDatabase::addApplicationFont(":/font/DIN-Medium.ttf");
if (font_id != -1) {
QString font_family = QFontDatabase::applicationFontFamilies(font_id).at(0);
QFont::insertSubstitution("DIN-Medium", font_family);
}
However, it still reports an warnning. -
Hi,
Do you mean you get the same warning ?
When are you doing your font adding ?
Which version of Qt are you using ?
On which OS ? -
The font family substitutes are only queried if the requested family does not exist, which is unknown as long as the population step has not happened. So that mechanism cannot be used to avoid the cost of populating aliases unfortunately, although you should end up resolving the correct font with this substitution in place.
If you really want to get rid of the extra cost, then you could store the result of applicationFontFamilies() somewhere central and query that instead of hardcoding the "DIN-Medium" name. But note that this is a one-time 215 ms cost. The aliases are cached in the database once they have been resolved.