GDI: Fix style name detection if font has no typographic subfamily name

This fixes the detection of font style names for the fonts "Bahnschrift"
and "Alef Bold" as described in Microsoft's documentation:
https://docs.microsoft.com/en-us/typography/opentype/spec/name

Fixes: QTBUG-101609
Fixes: QTBUG-101610
Pick-to: 6.3
Change-Id: I5bd2b72817c07195f1e98d1d924c6f673d9e24e0
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
bb10
Niklas Wenzel 2022-03-10 20:53:05 +01:00
parent cb65e4182f
commit b83fc8aafa
1 changed files with 7 additions and 1 deletions

View File

@ -558,7 +558,13 @@ static bool addFontToDatabase(QString familyName,
subFamilyStyle = styleName;
faceName = familyName; // Remember the original name for later lookups
familyName = canonicalNames.preferredName;
styleName = canonicalNames.preferredStyle;
// Preferred style / typographic subfamily name:
// "If it is absent, then name ID 2 is considered to be the typographic subfamily name."
// From: https://docs.microsoft.com/en-us/windows/win32/directwrite/opentype-variable-fonts
// Name ID 2 is already stored in the styleName variable. Furthermore, for variable fonts,
// styleName holds the variation instance name, which should be used over name ID 2.
if (!canonicalNames.preferredStyle.isEmpty())
styleName = canonicalNames.preferredStyle;
}
QSupportedWritingSystems writingSystems;