From 3b78f6d94b309708c7cd8961b09a6cfcc5caa022 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Wed, 5 May 2021 12:08:22 +0200 Subject: [PATCH] Windows: Work-around misreporting of Script and Roman Two legacy bitmap fonts are misreported as TMPF_VECTOR on Windows: Roman and Script. This causes them to be marked as scalable, and the automatic fallback to NativeRendering in Qt Quick does not kick in - causing the text elements to look empty instead. To work around this, we exploit the peculiarity that the type of these two fonts is reported as "0" in the enumeration, which is not a valid value. No other fonts on the system is reported as type 0, so we simply detect this error case and mark the fonts as non-scalable, which is the safer choice. [ChangeLog][Windows] Fixed text in "Roman" and "Script" bitmap fonts not showing in Qt Quick applications. Fixes: QTBUG-85826 Change-Id: Id889f0dedb1d529e6dd64c6da9e17e303f4a9d04 Reviewed-by: Allan Sandfeld Jensen (cherry picked from commit a1e405ce11eb6760ccca13cf1b4e5d20fa3916e9) Reviewed-by: Qt Cherry-pick Bot --- src/gui/text/windows/qwindowsfontdatabase.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/gui/text/windows/qwindowsfontdatabase.cpp b/src/gui/text/windows/qwindowsfontdatabase.cpp index 8e0c4f624b1..58ff99e3a86 100644 --- a/src/gui/text/windows/qwindowsfontdatabase.cpp +++ b/src/gui/text/windows/qwindowsfontdatabase.cpp @@ -522,7 +522,9 @@ static bool addFontToDatabase(QString familyName, const QString foundryName; // No such concept. const bool fixed = !(textmetric->tmPitchAndFamily & TMPF_FIXED_PITCH); const bool ttf = (textmetric->tmPitchAndFamily & TMPF_TRUETYPE); - const bool scalable = textmetric->tmPitchAndFamily & (TMPF_VECTOR|TMPF_TRUETYPE); + const bool unreliableTextMetrics = type == 0; + const bool scalable = (textmetric->tmPitchAndFamily & (TMPF_VECTOR|TMPF_TRUETYPE)) + && !unreliableTextMetrics; const int size = scalable ? SMOOTH_SCALABLE : textmetric->tmHeight; const QFont::Style style = textmetric->tmItalic ? QFont::StyleItalic : QFont::StyleNormal; const bool antialias = false;