diff options
author | Tor Arne Vestbø <tor.arne.vestbo@qt.io> | 2022-03-29 15:35:47 +0000 |
---|---|---|
committer | Tor Arne Vestbø <tor.arne.vestbo@qt.io> | 2022-03-29 23:26:37 +0000 |
commit | 344e0e7141667686a7e093aa76441bf2c43b6633 (patch) | |
tree | caa0a95e12a4f300f7f2d80ab18be94ed62a5be5 | |
parent | 9a74d94ff5fa63bfb23dcad1209e2844ef39908b (diff) |
Revert "Avoid populating font family aliases if family matched"
This reverts commit 69d525a6fa19934b3e57f503132bb4ab19f6b923.
The change introduced behavior changes on Windows, where family
aliases are used to build a full set of styles for a family.
Change-Id: I64ca1cf5febf0a6277cbe0a0041ccdb76da72196
Pick-to: 6.3 6.2 5.15
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
-rw-r--r-- | src/gui/text/qfontdatabase.cpp | 24 |
1 files changed, 9 insertions, 15 deletions
diff --git a/src/gui/text/qfontdatabase.cpp b/src/gui/text/qfontdatabase.cpp index 0ee8423edc..7012ca0869 100644 --- a/src/gui/text/qfontdatabase.cpp +++ b/src/gui/text/qfontdatabase.cpp @@ -905,13 +905,6 @@ static QtFontStyle *bestStyle(QtFontFoundry *foundry, const QtFontStyle::Key &st return foundry->styles[best]; } -enum { - FamilyMismatch = 0x800000, - ScriptMismatch = 0x080000, - PitchMismatch = 0x004000, - StyleMismatch = 0x002000, - BitmapScaledPenalty = 0x001000 -}; static unsigned int bestFoundry(int script, unsigned int score, int styleStrategy, @@ -1015,16 +1008,20 @@ unsigned int bestFoundry(int script, unsigned int score, int styleStrategy, unsigned int this_score = 0x0000; - + enum { + PitchMismatch = 0x4000, + StyleMismatch = 0x2000, + BitmapScaledPenalty = 0x1000 + }; if (pitch != '*') { if ((pitch == 'm' && !family->fixedPitch) || (pitch == 'p' && family->fixedPitch)) - this_score |= PitchMismatch; + this_score += PitchMismatch; } if (styleKey != style->key) - this_score |= StyleMismatch; + this_score += StyleMismatch; if (!style->smoothScalable && px != size->pixelSize) // bitmap scaled - this_score |= BitmapScaledPenalty; + this_score += BitmapScaledPenalty; if (px != pixelSize) // close, but not exact, size match this_score += qAbs(px - pixelSize); @@ -1109,14 +1106,11 @@ static int match(int script, if (!matchFamilyName(family_name, test.family)) continue; - score &= ~FamilyMismatch; - test.family->ensurePopulated(); // Check if family is supported in the script we want if (writingSystem != QFontDatabase::Any && !familySupportsWritingSystem(test.family, writingSystem)) continue; - score &= ~ScriptMismatch; // as we know the script is supported, we can be sure // to find a matching font here. @@ -2416,7 +2410,7 @@ QFontEngine *QFontDatabasePrivate::findFont(const QFontDef &req, QList<int> blackListed; unsigned int score = UINT_MAX; int index = match(multi ? QChar::Script_Common : script, request, family_name, foundry_name, &desc, blackListed, &score); - if ((score & FamilyMismatch) && QGuiApplicationPrivate::platformIntegration()->fontDatabase()->populateFamilyAliases(family_name)) { + if (score > 0 && QGuiApplicationPrivate::platformIntegration()->fontDatabase()->populateFamilyAliases(family_name)) { // We populated family aliases (e.g. localized families), so try again index = match(multi ? QChar::Script_Common : script, request, family_name, foundry_name, &desc, blackListed); } |