summaryrefslogtreecommitdiffstats
path: root/src/platformsupport/fontdatabases
diff options
context:
space:
mode:
authorEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>2019-07-30 08:59:15 +0200
committerEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>2019-07-30 09:10:01 +0200
commit31753adebe0f19b90f332e81e1a9b063b40f982d (patch)
tree2136f543b47508ba67c3b217aff8564ae596a837 /src/platformsupport/fontdatabases
parent111df3b5e04ffc6467be08bb84990aba48bf6b5a (diff)
Revert "Fontconfig font database: Short-circuit matching by filename"
This reverts commit eea99e1e8f3eb67fda35dd3a656fe9b5a9be84f2. The call to FcFreeTypeQuery() takes over 300 ms for NotoSansCJK-Regular.ttc and friends, so in the current state, this change cannot be used. I am not sure why these file in particular takes so long, but it might be because it is large (around 19MB) or because it is a font collection. The original fix was intended to be a smaller performance optimization, but it has added over 2 seconds startup time to simple applications showing Chinese text, so we revert it for now and it can be resubmitted later when the problems have been ironed out. Task-number: QTBUG-77108 Change-Id: Ibb2ef799573d7effd1595d788939fe33d82cc923 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'src/platformsupport/fontdatabases')
-rw-r--r--src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp72
1 files changed, 22 insertions, 50 deletions
diff --git a/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp b/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp
index e28b40c240..7abf295782 100644
--- a/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp
+++ b/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp
@@ -927,66 +927,38 @@ void QFontconfigDatabase::setupFontEngine(QFontEngineFT *engine, const QFontDef
antialias = antialiasingEnabled - 1;
}
- // try to find a match for fid
- const QFontEngine::FaceId fid = engine->faceId();
+ QFontEngine::GlyphFormat format;
+ // try and get the pattern
FcPattern *pattern = FcPatternCreate();
- FcPattern *match = nullptr;
-
- // try a trivial match by filename - FC_FILE is highest priority, so if it matches, FcFontMatch
- // will just find the file (fine) and spend a millisecond or so doing unnecessary work (bad).
- if (!fid.filename.isEmpty() && QFile::exists(QString::fromUtf8(fid.filename))) {
- FcBlanks *blanks = FcConfigGetBlanks(nullptr);
- int count = 0;
- FcPattern *fileMatch = FcFreeTypeQuery((const FcChar8 *)fid.filename.data(), fid.index,
- blanks, &count);
- if (fileMatch) {
- // Apply Fontconfig configuration - FcFreeTypeQuery only returns information stored in
- // the font file, we also want to respect system and user settings.
- FcConfigSubstitute(0, pattern, FcMatchPattern);
- FcDefaultSubstitute(pattern);
- match = FcFontRenderPrepare(0, pattern, fileMatch);
- FcPatternDestroy(fileMatch);
- }
- }
- if (!match) {
- FcValue value;
+ FcValue value;
+ value.type = FcTypeString;
+ QByteArray cs = fontDef.family.toUtf8();
+ value.u.s = (const FcChar8 *)cs.data();
+ FcPatternAdd(pattern,FC_FAMILY,value,true);
- // Fontconfig rules might process this information for arbitrary purposes, so add it,
- // even though we already know that it doesn't match an existing file.
- if (!fid.filename.isEmpty()) {
- value.type = FcTypeString;
- value.u.s = (const FcChar8 *)fid.filename.data();
- FcPatternAdd(pattern, FC_FILE, value, true);
+ QFontEngine::FaceId fid = engine->faceId();
- value.type = FcTypeInteger;
- value.u.i = fid.index;
- FcPatternAdd(pattern, FC_INDEX, value, true);
- }
+ if (!fid.filename.isEmpty()) {
+ value.u.s = (const FcChar8 *)fid.filename.data();
+ FcPatternAdd(pattern,FC_FILE,value,true);
- const QByteArray cs = fontDef.family.toUtf8();
- value.type = FcTypeString;
- value.u.s = (const FcChar8 *)cs.data();
- FcPatternAdd(pattern, FC_FAMILY, value, true);
-
- if (fontDef.pixelSize > 0.1) {
- value.type = FcTypeDouble;
- value.u.d = fontDef.pixelSize;
- FcPatternAdd(pattern, FC_PIXEL_SIZE, value, true);
- }
+ value.type = FcTypeInteger;
+ value.u.i = fid.index;
+ FcPatternAdd(pattern,FC_INDEX,value,true);
+ }
- FcResult result;
+ if (fontDef.pixelSize > 0.1)
+ FcPatternAddDouble(pattern, FC_PIXEL_SIZE, fontDef.pixelSize);
- FcConfigSubstitute(0, pattern, FcMatchPattern);
- FcDefaultSubstitute(pattern);
+ FcResult result;
- match = FcFontMatch(0, pattern, &result);
- }
+ FcConfigSubstitute(0, pattern, FcMatchPattern);
+ FcDefaultSubstitute(pattern);
- QFontEngine::GlyphFormat format;
+ FcPattern *match = FcFontMatch(0, pattern, &result);
if (match) {
- engine->setDefaultHintStyle(defaultHintStyleFromMatch(
- (QFont::HintingPreference)fontDef.hintingPreference, match, useXftConf));
+ engine->setDefaultHintStyle(defaultHintStyleFromMatch((QFont::HintingPreference)fontDef.hintingPreference, match, useXftConf));
FcBool fc_autohint;
if (FcPatternGetBool(match, FC_AUTOHINT,0, &fc_autohint) == FcResultMatch)