Revert "Windows: Add synthesized fonts also when there is a style name"
This is a partial revert of commit f385b8827a75688b8a2cbd51e8da8a602d7f9567. This causes issues because we may overwrite genuine styles with synthetic ones. Lets say for instance that we register "Roboto Bold" and then later we register "Roboto Thin". When we register "Roboto Thin" we also register an alternative font which is called "Roboto" (because this is the typographical family name of the font) with bold weight, because we know Windows can synthesize this. This would work fine, except that on Windows we also store the original face name of the font as a user-pointer in the database. This contains the legacy name of the font: "Roboto Thin". This will override the font that is already stored. When we look up "Roboto" + bold weight in the database later, we will find this synthetic font, replace the requested family name with the legacy one "Roboto Thin" and use this instead. The right fix for now is to revert the cause of the regression. If we want to re-fix the original bug, we might be able to reintroduce f385b8827a75688b8a2cbd51e8da8a602d7f9567 and then make sure we always prefer the "real" font when there are conflicts (this would mean marking synthetic fonts in the database). [ChangeLog][Windows] Fixed a regression where different font styles and/or weights would not be available. Fixes: QTBUG-94781 Task-number: QTBUG-91398 Change-Id: I092022b14ebf1d56685eaa3b8efe55f015659adc Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io> (cherry picked from commit d16ee17a39252e06bf3bef08d80b0d116c473ba1) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
52f93a88eb
commit
f63f4b3e62
@ -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)
|
||||
if (weight <= QFont::DemiBold && styleName.isEmpty())
|
||||
QPlatformFontDatabase::registerFont(familyName, QString(), foundryName, QFont::Bold,
|
||||
style, stretch, antialias, scalable, size, fixed, writingSystems, createFontFile(faceName));
|
||||
if (style != QFont::StyleItalic)
|
||||
if (style != QFont::StyleItalic && styleName.isEmpty())
|
||||
QPlatformFontDatabase::registerFont(familyName, QString(), foundryName, weight,
|
||||
QFont::StyleItalic, stretch, antialias, scalable, size, fixed, writingSystems, createFontFile(faceName));
|
||||
if (weight <= QFont::DemiBold && style != QFont::StyleItalic)
|
||||
if (weight <= QFont::DemiBold && style != QFont::StyleItalic && styleName.isEmpty())
|
||||
QPlatformFontDatabase::registerFont(familyName, QString(), foundryName, QFont::Bold,
|
||||
QFont::StyleItalic, stretch, antialias, scalable, size, fixed, writingSystems, createFontFile(faceName));
|
||||
|
||||
|
@ -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)
|
||||
if (weight <= QFont::DemiBold && styleName.isEmpty())
|
||||
QPlatformFontDatabase::registerFont(familyName, QString(), foundryName, QFont::Bold, style, stretch,
|
||||
antialias, scalable, size, fixed, writingSystems, createFontFile(value, index));
|
||||
|
||||
if (style != QFont::StyleItalic)
|
||||
if (style != QFont::StyleItalic && styleName.isEmpty())
|
||||
QPlatformFontDatabase::registerFont(familyName, QString(), foundryName, weight, QFont::StyleItalic, stretch,
|
||||
antialias, scalable, size, fixed, writingSystems, createFontFile(value, index));
|
||||
|
||||
if (weight <= QFont::DemiBold && style != QFont::StyleItalic)
|
||||
if (weight <= QFont::DemiBold && style != QFont::StyleItalic && styleName.isEmpty())
|
||||
QPlatformFontDatabase::registerFont(familyName, QString(), foundryName, QFont::Bold, QFont::StyleItalic, stretch,
|
||||
antialias, scalable, size, fixed, writingSystems, createFontFile(value, index));
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user