Solved How to check whether a font is the requested font
-
I'm working on a project where we check whether a specific font is installed when running on Linux. We recently upgraded our Qt version from 5.9.6 to 5.15.1. With 5.9.6 we did:
bool isFontInstalled() { return QFont("Verdana").exactMatch(); }
Now, with 5.15.1, this returns false even when Verdana is installed. I've tried:
bool isFontInstalled() { QFontDatabase db; auto fontFromDB = db.font( "Verdana", "", 12 ); return fontFromDB.exactMatch(); }
But this also returns false. I've checked a few other font families,
QFont::exactMatch()
always returns false. Is this a bug? Or is there some way to construct a font that will be considered an "exact match" for Verdana? -
@Jessica-SnapGene said in How to check whether a font is the requested font:
Is this a bug?
Maybe, search the bugtracker and create one if you think it's a bug. Don't forget a simple reproducable example in the bugreport.
-
I logged this: https://bugreports.qt.io/browse/QTBUG-87267
Looks like it was a bug. I haven't confirmed whether or not it has been fixed, but there's a commit to 5.15 branch. I'll mark this topic solved.