QString QSGDistanceFieldGlyphCacheManager::fontKey(const QRawFont &font) { QFontEngine *fe = QRawFontPrivate::get(font)->fontEngine; if (!fe->faceId().filename.isEmpty()) { QByteArray keyName = fe->faceId().filename; if (font.style() != QFont::StyleNormal) keyName += QByteArray(" I"); if (font.weight() != QFont::Normal) keyName += ' ' + QByteArray::number(font.weight()); keyName += QByteArray(" DF"); return QString::fromUtf8(keyName); } else { return QString::fromLatin1("%1_%2_%3_%4") .arg(font.familyName()) .arg(font.styleName()) .arg(font.weight()) .arg(font.style()); } }
void tst_QRawFont::invalidRawFont() { QRawFont font; QVERIFY(!font.isValid()); QCOMPARE(font.pixelSize(), 0.0); QVERIFY(font.familyName().isEmpty()); QCOMPARE(font.style(), QFont::StyleNormal); QCOMPARE(font.weight(), -1); QCOMPARE(font.ascent(), 0.0); QCOMPARE(font.descent(), 0.0); QVERIFY(font.glyphIndexesForString(QLatin1String("Test")).isEmpty()); }