diff options
Diffstat (limited to 'src/gui/text/qfontdatabase.cpp')
-rw-r--r-- | src/gui/text/qfontdatabase.cpp | 43 |
1 files changed, 27 insertions, 16 deletions
diff --git a/src/gui/text/qfontdatabase.cpp b/src/gui/text/qfontdatabase.cpp index 9122f4db4e..43648d0f7f 100644 --- a/src/gui/text/qfontdatabase.cpp +++ b/src/gui/text/qfontdatabase.cpp @@ -406,9 +406,14 @@ QtFontFoundry *QtFontFamily::foundry(const QString &f, bool create) return foundries[count++]; } +static inline bool equalsCaseInsensitive(const QString &a, const QString &b) +{ + return a.size() == b.size() && a.compare(b, Qt::CaseInsensitive) == 0; +} + bool QtFontFamily::matchesFamilyName(const QString &familyName) const { - return name.compare(familyName, Qt::CaseInsensitive) == 0 || aliases.contains(familyName, Qt::CaseInsensitive); + return equalsCaseInsensitive(name, familyName) || aliases.contains(familyName, Qt::CaseInsensitive); } void QtFontFamily::ensurePopulated() @@ -663,11 +668,8 @@ struct QtFontDesc static void initFontDef(const QtFontDesc &desc, const QFontDef &request, QFontDef *fontDef, bool multi) { fontDef->family = desc.family->name; - if (! desc.foundry->name.isEmpty() && desc.family->count > 1) { - fontDef->family += QString::fromLatin1(" ["); - fontDef->family += desc.foundry->name; - fontDef->family += QLatin1Char(']'); - } + if (! desc.foundry->name.isEmpty() && desc.family->count > 1) + fontDef->family += QLatin1String(" [") + desc.foundry->name + QLatin1Char(']'); if (desc.style->smoothScalable || QGuiApplicationPrivate::platformIntegration()->fontDatabase()->fontsAlwaysScalable() @@ -956,12 +958,14 @@ QFontEngine *loadSingleEngine(int script, } } - // If the font data's native stretch matches the requested stretch we need to set stretch to 100 - // to avoid the fontengine synthesizing stretch. If they didn't match exactly we need to calculate - // the new stretch factor. This only done if not matched by styleName. + // To avoid synthesized stretch we need a matching stretch to be 100 after this point. + // If stretch didn't match exactly we need to calculate the new stretch factor. + // This only done if not matched by styleName. if (style->key.stretch != 0 && request.stretch != 0 && (request.styleName.isEmpty() || request.styleName != style->styleName)) { - def.stretch = (request.stretch * 100 + 50) / style->key.stretch; + def.stretch = (request.stretch * 100 + style->key.stretch / 2) / style->key.stretch; + } else { + def.stretch = 100; } engine = pfdb->fontEngine(def, size->handle); @@ -1225,7 +1229,8 @@ static int match(int script, const QFontDef &request, QtFontStyle::Key styleKey; styleKey.style = request.style; styleKey.weight = request.weight; - styleKey.stretch = request.stretch; + // Prefer a stretch closest to 100. + styleKey.stretch = request.stretch ? request.stretch : 100; char pitch = request.ignorePitch ? '*' : request.fixedPitch ? 'm' : 'p'; @@ -2221,10 +2226,18 @@ QString QFontDatabase::writingSystemSample(WritingSystem writingSystem) sample += QChar(0x05D3); break; case Arabic: + sample += QChar(0x0623); + sample += QChar(0x0628); + sample += QChar(0x062C); + sample += QChar(0x062F); + sample += QChar(0x064A); + sample += QChar(0x0629); + sample += QChar(0x0020); + sample += QChar(0x0639); + sample += QChar(0x0631); sample += QChar(0x0628); + sample += QChar(0x064A); sample += QChar(0x0629); - sample += QChar(0x062A); - sample += QChar(0x063A); break; case Syriac: sample += QChar(0x0715); @@ -2427,7 +2440,7 @@ int QFontDatabasePrivate::addAppFont(const QByteArray &fontData, const QString & } if (font.fileName.isEmpty() && !fontData.isEmpty()) - font.fileName = QString::fromLatin1(":qmemoryfonts/") + QString::number(i); + font.fileName = QLatin1String(":qmemoryfonts/") + QString::number(i); registerFont(&font); if (font.families.isEmpty()) @@ -2732,8 +2745,6 @@ void QFontDatabase::load(const QFontPrivate *d, int script) } if (req.pointSize < 0) req.pointSize = req.pixelSize*72.0/d->dpi; - if (req.stretch == 0) - req.stretch = 100; // respect the fallback families that might be passed through the request const QStringList fallBackFamilies = familyList(req); |