Details
-
Bug
-
Resolution: Unresolved
-
P3: Somewhat important
-
None
-
6.3.0 RC, 6.4.0
-
None
-
-platform windows:fontengine=freetype
Description
With the Freetype font backend, the following should report font weight 900 but currently reports font weight 400:
QFont font("Arial Black"); font.setStyleName("Black"); QFontInfo fontInfo(font); qDebug() << fontInfo.weight();
To run this code with the Freetype backend, add command line parameter -platform windows:fontengine=freetype when running the executable.
The issue was discovered in this code review comment: https://codereview.qt-project.org/c/qt/qtbase/+/399156/comment/6e62c91f_f07ac3c2/
The code works fine with the GDI backend if you change setStyleName("Black") to setStyleName("Regular") and apply this patch. (The styleName change is necessary because Freetype registers the font as family/subfamily "Arial Black"/"Black" whereas GDI treats it as "Arial Black"/"Regular". This inconsistency was also discovered in the code review comment linked above but wasn't seen as critical.)
Reproduction
More extensive code example attached.
Can also be tested with the tst_QFontDatabase::subFamilyMatching() test from https://codereview.qt-project.org/c/qt/qtbase/+/399156. The test should be adjusted after fixing this bug.