summaryrefslogtreecommitdiffstats
path: root/src/gui/text/windows
diff options
context:
space:
mode:
authorEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>2021-05-06 11:21:07 +0200
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2021-05-12 05:36:32 +0000
commitc5e6a063052075c931f9396b8e4b17541e9cfe35 (patch)
tree4f1b46c8f5e1af8b4c5ef7609197876d41ef3345 /src/gui/text/windows
parent516d8d22ff45da01ae9de367a39c129dd408246a (diff)
Windows: Add synthesized fonts also when there is a style name
Since Windows can synthesize certain font traits for us, we used to register these in the font database so that we could match against them. But after change 469b13916983aff4625657eecbb7d2399cac901d, this in principle no longer happens, because we opt out whenever there is a style name (which there usually is, this could be e.g. "Regular" for a normal font). The result of this was that if we looked for a bold variant of a font, we would not find it. In cases where a multi-engine was used, the request for bold would still survive in the multi engine's fontDef, so we would still pick it up later and apply the synthesis. But when NoFontMerging was set, then we would override the weight in the fontDef with the one from the font database. Since the comment documents that the additional registrations are there to make sure all the variants that Windows can synthesize are available for matching, it does not make sense to skip them just because the font has a style name. So this is a partial revert of 469b13916983aff4625657eecbb7d2399cac901d. Note: This exposed an error in QFontDatabase::isSmoothlyScalable(). The style parameter here is not the "styleName" (as in sub-family), but actually predates that API. Instead it is the "style" as returned by QFontDatabase::styles(), which may be the style name, but it can also be the generated description of the style and weight. In the latter case, we would return false for fonts that are actually smoothly scalable, which is incorrect. This caused a failure in tst_QFontMetrics::metrics(). To remedy this, we add an additional condition, and also match the style if it matches the generated descripion of the style key. [ChangeLog][Windows] Fixed an issue where bold/italic would not be synthesized for fonts if QFont::NoFontMerging was set. Fixes: QTBUG-91398 Change-Id: Id2166a47ae2d386536cf6e5e27ff09165ae8a23a Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io> (cherry picked from commit f385b8827a75688b8a2cbd51e8da8a602d7f9567) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'src/gui/text/windows')
-rw-r--r--src/gui/text/windows/qwindowsfontdatabase.cpp6
-rw-r--r--src/gui/text/windows/qwindowsfontdatabase_ft.cpp6
2 files changed, 6 insertions, 6 deletions
diff --git a/src/gui/text/windows/qwindowsfontdatabase.cpp b/src/gui/text/windows/qwindowsfontdatabase.cpp
index 58ff99e3a8..94a152abed 100644
--- a/src/gui/text/windows/qwindowsfontdatabase.cpp
+++ b/src/gui/text/windows/qwindowsfontdatabase.cpp
@@ -604,13 +604,13 @@ static bool addFontToDatabase(QString familyName,
style, stretch, antialias, scalable, size, fixed, writingSystems, createFontFile(faceName));
// add fonts windows can generate for us:
- if (weight <= QFont::DemiBold && styleName.isEmpty())
+ if (weight <= QFont::DemiBold)
QPlatformFontDatabase::registerFont(familyName, QString(), foundryName, QFont::Bold,
style, stretch, antialias, scalable, size, fixed, writingSystems, createFontFile(faceName));
- if (style != QFont::StyleItalic && styleName.isEmpty())
+ if (style != QFont::StyleItalic)
QPlatformFontDatabase::registerFont(familyName, QString(), foundryName, weight,
QFont::StyleItalic, stretch, antialias, scalable, size, fixed, writingSystems, createFontFile(faceName));
- if (weight <= QFont::DemiBold && style != QFont::StyleItalic && styleName.isEmpty())
+ if (weight <= QFont::DemiBold && style != QFont::StyleItalic)
QPlatformFontDatabase::registerFont(familyName, QString(), foundryName, QFont::Bold,
QFont::StyleItalic, stretch, antialias, scalable, size, fixed, writingSystems, createFontFile(faceName));
diff --git a/src/gui/text/windows/qwindowsfontdatabase_ft.cpp b/src/gui/text/windows/qwindowsfontdatabase_ft.cpp
index e2c8d3455d..c8dbba015c 100644
--- a/src/gui/text/windows/qwindowsfontdatabase_ft.cpp
+++ b/src/gui/text/windows/qwindowsfontdatabase_ft.cpp
@@ -279,15 +279,15 @@ static bool addFontToDatabase(QString familyName,
antialias, scalable, size, fixed, writingSystems, createFontFile(value, index));
// add fonts windows can generate for us:
- if (weight <= QFont::DemiBold && styleName.isEmpty())
+ if (weight <= QFont::DemiBold)
QPlatformFontDatabase::registerFont(familyName, QString(), foundryName, QFont::Bold, style, stretch,
antialias, scalable, size, fixed, writingSystems, createFontFile(value, index));
- if (style != QFont::StyleItalic && styleName.isEmpty())
+ if (style != QFont::StyleItalic)
QPlatformFontDatabase::registerFont(familyName, QString(), foundryName, weight, QFont::StyleItalic, stretch,
antialias, scalable, size, fixed, writingSystems, createFontFile(value, index));
- if (weight <= QFont::DemiBold && style != QFont::StyleItalic && styleName.isEmpty())
+ if (weight <= QFont::DemiBold && style != QFont::StyleItalic)
QPlatformFontDatabase::registerFont(familyName, QString(), foundryName, QFont::Bold, QFont::StyleItalic, stretch,
antialias, scalable, size, fixed, writingSystems, createFontFile(value, index));