diff options
author | Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io> | 2019-04-02 15:33:16 +0200 |
---|---|---|
committer | Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io> | 2019-05-23 09:49:10 +0200 |
commit | 922d195020d54d7e599d135f6a5e0338100e08f1 (patch) | |
tree | 5ca0bfce1b904ce40d06dc38c2e3c3b7e3301b3f /src/gui/text/qfontdatabase.cpp | |
parent | cceeb1ee7e18aac2a21ec72ef669bd6d4490ce2e (diff) |
Fix font matching of typographic families on Windows
9204b8c31ea1b5f0c05870c5b5d74c33b1a4f622 broke font matching on Windows.
This was then attempted fixed by bcd2fa484a4fe93e77743195d7f72cce9e580d43,
but this caused an infinite recursion for some cases, so it was reverted
again by 9d1905da9c59e9062a157199c81c076efc20eb28.
The original issue was that if we populate a specific face of a family,
such as "Arial Black", then the typographic/preferred name will be
detected as "Arial" and this family will be set as populated=true, even
though we have not yet registered any additional subfamilies. In this case,
we need to call populateFamily() for the typographic family name to
ensure we get Windows to enumerate all the subfamilies in that family
before it sets it as populated=true.
But this broke for some fonts where the font naming was unconventional.
In particular, "Yu Gothic" would have its Japanese name as the
typographic name, and there would be no font in the system where
the old-style font family name matched the typographic name. In
that case we would go into a loop where we would try populating
"<Japanese font name>", Windows would translate this to "Yu Gothic", we would
translate it back to "<Japanese font name>", ad infinitum.
In order to avoid the infinite recursion, we add a recursion guard
as well, ensuring that we never call populateFamily() for the main
family we are currently populating.
[ChangeLog][Windows][Fonts] Fixed a bug where it would be impossible
to request different faces of a font family after a specific type face
has been in use.
Task-number: QTBUG-74748
Task-number: QTBUG-74983
Change-Id: Ibe6239f67c45d67ebf75947c8f231cfa177e347f
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'src/gui/text/qfontdatabase.cpp')
-rw-r--r-- | src/gui/text/qfontdatabase.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/gui/text/qfontdatabase.cpp b/src/gui/text/qfontdatabase.cpp index 82b9bb810a..3cbda0facd 100644 --- a/src/gui/text/qfontdatabase.cpp +++ b/src/gui/text/qfontdatabase.cpp @@ -792,6 +792,13 @@ QString qt_resolveFontFamilyAlias(const QString &alias) return alias; } +bool qt_isFontFamilyPopulated(const QString &familyName) +{ + QFontDatabasePrivate *d = privateDb(); + QtFontFamily *f = d->family(familyName, QFontDatabasePrivate::RequestFamily); + return f != nullptr && f->populated; +} + /*! Returns a list of alternative fonts for the specified \a family and \a style and \a script using the \a styleHint given. |