From b83fc8aafae72327951c178b3b42ac7bc0d8cefa Mon Sep 17 00:00:00 2001 From: Niklas Wenzel Date: Thu, 10 Mar 2022 20:53:05 +0100 Subject: [PATCH] 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 --- src/gui/text/windows/qwindowsfontdatabase.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/gui/text/windows/qwindowsfontdatabase.cpp b/src/gui/text/windows/qwindowsfontdatabase.cpp index da196880f8..4fb8d2dce3 100644 --- a/src/gui/text/windows/qwindowsfontdatabase.cpp +++ b/src/gui/text/windows/qwindowsfontdatabase.cpp @@ -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;