summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/windows/qwindowsfontdatabase.cpp
diff options
context:
space:
mode:
authorEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>2016-09-21 14:55:00 +0200
committerEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>2016-09-22 10:29:49 +0000
commit036639c2b575de238a519cb029c4ba70d4c8980d (patch)
treec6d449fae7a51cecaa5d295c8f9a23b723148ad3 /src/plugins/platforms/windows/qwindowsfontdatabase.cpp
parent27d2593e6d7b2474bbd14e4d5a40561ae81a448b (diff)
Windows/freetype: Fix loading non-regular fonts
When resolving the filenames of fonts, we would first match against the font face name, meaning that an italic font, for instance would always be matched to the file of the regular font in the same face. To fix this, we look up the full name in the file name cache first, before the face name. Also, since the font names in the registry are the English names, but the names we get when enumerating the fonts on the system can be localized on non-English locales, we need to translate the full name of the font before we give up on matching it against the registry. Since this can be a heavy operation, we add a cut-off which skips resolving the English name when the style is one of the most common "Italic" or "Bold" since we know these to be English. [ChangeLog][QtGui][Windows] Fix selecting non-regular fonts when using the Freetype engine. Task-number: QTBUG-47485 Change-Id: If897abb93dc93263902b1c62bc3f66c4d06721c2 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'src/plugins/platforms/windows/qwindowsfontdatabase.cpp')
-rw-r--r--src/plugins/platforms/windows/qwindowsfontdatabase.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/plugins/platforms/windows/qwindowsfontdatabase.cpp b/src/plugins/platforms/windows/qwindowsfontdatabase.cpp
index 9f2d0c8a33..04b9530890 100644
--- a/src/plugins/platforms/windows/qwindowsfontdatabase.cpp
+++ b/src/plugins/platforms/windows/qwindowsfontdatabase.cpp
@@ -908,7 +908,7 @@ static FontNames getCanonicalFontNames(const uchar *table, quint32 bytes)
} // namespace
-QString getEnglishName(const QString &familyName)
+QString getEnglishName(const QString &familyName, bool includeStyle = false)
{
QString i18n_name;
QString faceName = familyName;
@@ -946,7 +946,12 @@ QString getEnglishName(const QString &familyName)
if ( bytes == GDI_ERROR )
goto error;
- i18n_name = getCanonicalFontNames(table, bytes).name;
+ {
+ const FontNames names = getCanonicalFontNames(table, bytes);
+ i18n_name = names.name;
+ if (includeStyle)
+ i18n_name += QLatin1Char(' ') + names.style;
+ }
error:
delete [] table;
SelectObject( hdc, oldobj );