summaryrefslogtreecommitdiffstats
path: root/src/gui/text/qfontdatabase.cpp
diff options
context:
space:
mode:
authorEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>2021-02-09 10:23:49 +0100
committerEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>2021-03-11 11:55:46 +0100
commit7fd9ed32012bd9001e78ad692a4802e0e3366e44 (patch)
tree5dcbd8692d3e1b741fae5b0e72af1714d5574b16 /src/gui/text/qfontdatabase.cpp
parent3416e5423eeb10bdcde59a8ed3aedf9e987bafd2 (diff)
Support family names that end/start with space
If the family name starts or ends with a space in the actual font data, then this would not be selectable by Qt. This is because we trim the family name before matching it against the contents of the database. Testing on Windows GDI, it actually does trim the spaces on the family names (matching a request for "Chibola" with a font called "Chibola " for instance), but since we read the font data ourselves, we are not doing this. To ensure we never have font names that cannot be matched in the database, we make sure we trim the family names before registering them. [ChangeLog][QtGui][Text] Fixed matching against fonts which has a family name that ends or starts with a space. Task-number: QTBUG-79140 Pick-to: 6.1 Pick-to: 6.0 Pick-to: 5.15 Change-Id: I9cdb50b78a7da2d2697f992ce462033eb1d7ada7 Reviewed-by: Andy Shaw <andy.shaw@qt.io>
Diffstat (limited to 'src/gui/text/qfontdatabase.cpp')
-rw-r--r--src/gui/text/qfontdatabase.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/gui/text/qfontdatabase.cpp b/src/gui/text/qfontdatabase.cpp
index 1968838691..b35cef6a9a 100644
--- a/src/gui/text/qfontdatabase.cpp
+++ b/src/gui/text/qfontdatabase.cpp
@@ -304,10 +304,12 @@ void QFontDatabasePrivate::invalidate()
emit static_cast<QGuiApplication *>(QCoreApplication::instance())->fontDatabaseChanged();
}
-QtFontFamily *QFontDatabasePrivate::family(const QString &f, FamilyRequestFlags flags)
+QtFontFamily *QFontDatabasePrivate::family(const QString &family, FamilyRequestFlags flags)
{
QtFontFamily *fam = nullptr;
+ const QString f = family.trimmed();
+
int low = 0;
int high = count;
int pos = count / 2;