QFont: Prefer setFamilies() over setFamily()
By depending on setFamilies() then we can be sure that font names with spaces, commas, quotes and so on are correctly handled without being misinterpreted. For now it will split on the comma when a string containing one is passed to setFamily. But from Qt 6.2 this will be removed to preserve the family string as a convenience function. [ChangeLog][QtGui][QFont] Indicated that setFamilies/families is preferred over setFamily/family to ensure that font family names are preserved when spaces, commas and so on are used in the name. Change-Id: Id3c1a4e827756a4c928fed461a4aafa5a0f06633 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
This commit is contained in:
parent
13c460d0ff
commit
d8602ce58b
@ -3876,7 +3876,7 @@ void QPainter::setFont(const QFont &font)
|
||||
|
||||
#ifdef QT_DEBUG_DRAW
|
||||
if (qt_show_painter_debug_output)
|
||||
printf("QPainter::setFont(), family=%s, pointSize=%d\n", font.family().toLatin1().constData(), font.pointSize());
|
||||
printf("QPainter::setFont(), family=%s, pointSize=%d\n", font.families().first().toLatin1().constData(), font.pointSize());
|
||||
#endif
|
||||
|
||||
if (!d->engine) {
|
||||
|
@ -224,7 +224,7 @@ void QCoreTextFontEngine::init()
|
||||
face_id.filename = QString::fromCFString(name).toUtf8();
|
||||
|
||||
QCFString family = CTFontCopyFamilyName(ctfont);
|
||||
fontDef.family = family;
|
||||
fontDef.families = QStringList(family);
|
||||
|
||||
QCFString styleName = (CFStringRef) CTFontCopyAttribute(ctfont, kCTFontStyleNameAttribute);
|
||||
fontDef.styleName = styleName;
|
||||
|
@ -629,7 +629,7 @@ namespace {
|
||||
|
||||
void updateFamilyNameAndStyle()
|
||||
{
|
||||
fontDef.family = QString::fromLatin1(freetype->face->family_name);
|
||||
fontDef.families = QStringList(QString::fromLatin1(freetype->face->family_name));
|
||||
|
||||
if (freetype->face->style_flags & FT_STYLE_FLAG_ITALIC)
|
||||
fontDef.style = QFont::StyleItalic;
|
||||
@ -734,7 +734,7 @@ bool QFontEngineFT::init(FaceId faceId, bool antialias, GlyphFormat format,
|
||||
PS_FontInfoRec psrec;
|
||||
// don't assume that type1 fonts are symbol fonts by default
|
||||
if (FT_Get_PS_Font_Info(freetype->face, &psrec) == FT_Err_Ok) {
|
||||
symbol = bool(fontDef.family.contains(QLatin1String("symbol"), Qt::CaseInsensitive));
|
||||
symbol = bool(fontDef.families.first().contains(QLatin1String("symbol"), Qt::CaseInsensitive));
|
||||
}
|
||||
|
||||
freetype->computeSize(fontDef, &xsize, &ysize, &defaultGlyphSet.outline_drawing, &scalableBitmapScaleFactor);
|
||||
@ -1210,7 +1210,7 @@ QFontEngine::Properties QFontEngineFT::properties() const
|
||||
{
|
||||
Properties p = freetype->properties();
|
||||
if (p.postscriptName.isEmpty()) {
|
||||
p.postscriptName = QFontEngine::convertToPostscriptFontFamilyName(fontDef.family.toUtf8());
|
||||
p.postscriptName = QFontEngine::convertToPostscriptFontFamilyName(fontDef.families.first().toUtf8());
|
||||
}
|
||||
|
||||
return freetype->properties();
|
||||
|
@ -1230,7 +1230,6 @@ static bool setFontFamilyFromValues(const QList<QCss::Value> &values, QFont *fon
|
||||
families << family;
|
||||
if (families.isEmpty())
|
||||
return false;
|
||||
font->setFamily(families.at(0));
|
||||
font->setFamilies(families);
|
||||
return true;
|
||||
}
|
||||
|
@ -116,37 +116,14 @@ bool QFontDef::exactMatch(const QFontDef &other) const
|
||||
if (stretch != 0 && other.stretch != 0 && stretch != other.stretch)
|
||||
return false;
|
||||
|
||||
// If either families or other.families just has 1 entry and the other has 0 then
|
||||
// we will fall back to using the family in that case
|
||||
const int sizeDiff = qAbs(families.size() - other.families.size());
|
||||
if (sizeDiff > 1)
|
||||
return false;
|
||||
if (sizeDiff == 1 && (families.size() > 1 || other.families.size() > 1))
|
||||
return false;
|
||||
|
||||
QStringList origFamilies = families;
|
||||
QStringList otherFamilies = other.families;
|
||||
if (sizeDiff != 0) {
|
||||
if (origFamilies.size() != 1)
|
||||
origFamilies << family;
|
||||
else
|
||||
otherFamilies << other.family;
|
||||
}
|
||||
|
||||
QString this_family, this_foundry, other_family, other_foundry;
|
||||
for (int i = 0; i < origFamilies.size(); ++i) {
|
||||
QFontDatabasePrivate::parseFontName(origFamilies.at(i), this_foundry, this_family);
|
||||
QFontDatabasePrivate::parseFontName(otherFamilies.at(i), other_foundry, other_family);
|
||||
for (int i = 0; i < families.size(); ++i) {
|
||||
QFontDatabasePrivate::parseFontName(families.at(i), this_foundry, this_family);
|
||||
QFontDatabasePrivate::parseFontName(other.families.at(i), other_foundry, other_family);
|
||||
if (this_family != other_family || this_foundry != other_foundry)
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check family only if families is not set
|
||||
if (origFamilies.size() == 0) {
|
||||
QFontDatabasePrivate::parseFontName(family, this_foundry, this_family);
|
||||
QFontDatabasePrivate::parseFontName(other.family, other_foundry, other_family);
|
||||
}
|
||||
|
||||
return (styleHint == other.styleHint
|
||||
&& styleStrategy == other.styleStrategy
|
||||
&& weight == other.weight
|
||||
@ -225,6 +202,24 @@ static int convertWeights(int weight, bool inverted)
|
||||
return result;
|
||||
}
|
||||
|
||||
// Splits the family string on a comma and returns the list based on that
|
||||
static QStringList splitIntoFamilies(const QString &family)
|
||||
{
|
||||
QStringList familyList;
|
||||
const auto list = QStringView{family}.split(QLatin1Char(','));
|
||||
const int numFamilies = list.size();
|
||||
familyList.reserve(numFamilies);
|
||||
for (int i = 0; i < numFamilies; ++i) {
|
||||
auto str = list.at(i).trimmed();
|
||||
if ((str.startsWith(QLatin1Char('"')) && str.endsWith(QLatin1Char('"')))
|
||||
|| (str.startsWith(QLatin1Char('\'')) && str.endsWith(QLatin1Char('\'')))) {
|
||||
str = str.mid(1, str.length() - 2);
|
||||
}
|
||||
familyList << str.toString();
|
||||
}
|
||||
return familyList;
|
||||
}
|
||||
|
||||
/* Converts from legacy Qt font weight (Qt < 6.0) to OpenType font weight (Qt >= 6.0) */
|
||||
Q_GUI_EXPORT int qt_legacyToOpenTypeWeight(int weight)
|
||||
{
|
||||
@ -326,16 +321,8 @@ void QFontPrivate::resolve(uint mask, const QFontPrivate *other)
|
||||
if ((mask & QFont::AllPropertiesResolved) == QFont::AllPropertiesResolved) return;
|
||||
|
||||
// assign the unset-bits with the set-bits of the other font def
|
||||
if (! (mask & QFont::FamilyResolved))
|
||||
request.family = other->request.family;
|
||||
|
||||
if (!(mask & QFont::FamiliesResolved)) {
|
||||
if (!(mask & QFont::FamiliesResolved))
|
||||
request.families = other->request.families;
|
||||
// Prepend the family explicitly set so it will be given
|
||||
// preference in this case
|
||||
if (mask & QFont::FamilyResolved)
|
||||
request.families.prepend(request.family);
|
||||
}
|
||||
|
||||
if (! (mask & QFont::StyleNameResolved))
|
||||
request.styleName = other->request.styleName;
|
||||
@ -709,6 +696,7 @@ QFont::QFont()
|
||||
}
|
||||
|
||||
/*!
|
||||
\obsolete
|
||||
Constructs a font object with the specified \a family, \a
|
||||
pointSize, \a weight and \a italic settings.
|
||||
|
||||
@ -723,11 +711,15 @@ QFont::QFont()
|
||||
available a family will be set using the \l{QFont}{font matching}
|
||||
algorithm.
|
||||
|
||||
This will split the family string on a comma and call setFamilies() with the
|
||||
resulting list. To preserve a font that uses a comma in its name, use
|
||||
the constructor that takes a QStringList.
|
||||
|
||||
\sa Weight, setFamily(), setPointSize(), setWeight(), setItalic(),
|
||||
setStyleHint(), QGuiApplication::font()
|
||||
setStyleHint(), setFamilies(), QGuiApplication::font()
|
||||
*/
|
||||
QFont::QFont(const QString &family, int pointSize, int weight, bool italic)
|
||||
: d(new QFontPrivate()), resolve_mask(QFont::FamilyResolved)
|
||||
: d(new QFontPrivate()), resolve_mask(QFont::FamiliesResolved)
|
||||
{
|
||||
if (pointSize <= 0) {
|
||||
pointSize = 12;
|
||||
@ -744,7 +736,48 @@ QFont::QFont(const QString &family, int pointSize, int weight, bool italic)
|
||||
if (italic)
|
||||
resolve_mask |= QFont::StyleResolved;
|
||||
|
||||
d->request.family = family;
|
||||
d->request.families = splitIntoFamilies(family);
|
||||
d->request.pointSize = qreal(pointSize);
|
||||
d->request.pixelSize = -1;
|
||||
d->request.weight = weight;
|
||||
d->request.style = italic ? QFont::StyleItalic : QFont::StyleNormal;
|
||||
}
|
||||
|
||||
/*!
|
||||
Constructs a font object with the specified \a families, \a
|
||||
pointSize, \a weight and \a italic settings.
|
||||
|
||||
If \a pointSize is zero or negative, the point size of the font
|
||||
is set to a system-dependent default value. Generally, this is
|
||||
12 points.
|
||||
|
||||
Each family name entry in \a families may optionally also include
|
||||
a foundry name, e.g. "Helvetica [Cronyx]". If the family is
|
||||
available from more than one foundry and the foundry isn't
|
||||
specified, an arbitrary foundry is chosen. If the family isn't
|
||||
available a family will be set using the \l{QFont}{font matching}
|
||||
algorithm.
|
||||
|
||||
\sa Weight, setPointSize(), setWeight(), setItalic(),
|
||||
setStyleHint(), setFamilies(), QGuiApplication::font()
|
||||
*/
|
||||
QFont::QFont(const QStringList &families, int pointSize, int weight, bool italic)
|
||||
: d(new QFontPrivate()), resolve_mask(QFont::FamiliesResolved)
|
||||
{
|
||||
if (pointSize <= 0)
|
||||
pointSize = 12;
|
||||
else
|
||||
resolve_mask |= QFont::SizeResolved;
|
||||
|
||||
if (weight < 0)
|
||||
weight = Normal;
|
||||
else
|
||||
resolve_mask |= QFont::WeightResolved | QFont::StyleResolved;
|
||||
|
||||
if (italic)
|
||||
resolve_mask |= QFont::StyleResolved;
|
||||
|
||||
d->request.families = families;
|
||||
d->request.pointSize = qreal(pointSize);
|
||||
d->request.pixelSize = -1;
|
||||
d->request.weight = weight;
|
||||
@ -785,14 +818,14 @@ QFont &QFont::operator=(const QFont &font)
|
||||
*/
|
||||
|
||||
/*!
|
||||
Returns the requested font family name, i.e. the name set in the
|
||||
constructor or the last setFont() call.
|
||||
Returns the requested font family name. This will always be the same
|
||||
as the first entry in the families() call.
|
||||
|
||||
\sa setFamily(), substitutes(), substitute()
|
||||
\sa setFamily(), substitutes(), substitute(), setFamilies(), families()
|
||||
*/
|
||||
QString QFont::family() const
|
||||
{
|
||||
return d->request.family;
|
||||
return d->request.families.first();
|
||||
}
|
||||
|
||||
/*!
|
||||
@ -806,18 +839,22 @@ QString QFont::family() const
|
||||
available a family will be set using the \l{QFont}{font matching}
|
||||
algorithm.
|
||||
|
||||
\sa family(), setStyleHint(), QFontInfo
|
||||
This will split the family string on a comma and call setFamilies() with the
|
||||
resulting list. To preserve a font that uses a comma in it's name then use
|
||||
setFamilies() directly. From Qt 6.2 this behavior will no longer happen and
|
||||
\a family will be passed as a single family.
|
||||
|
||||
\sa family(), setStyleHint(), setFamilies(), families(), QFontInfo
|
||||
*/
|
||||
void QFont::setFamily(const QString &family)
|
||||
{
|
||||
if ((resolve_mask & QFont::FamilyResolved) && d->request.family == family)
|
||||
return;
|
||||
|
||||
detach();
|
||||
|
||||
d->request.family = family;
|
||||
|
||||
resolve_mask |= QFont::FamilyResolved;
|
||||
#ifdef QT_DEBUG
|
||||
if (family.contains(QLatin1Char(','))) {
|
||||
qWarning("From Qt 6.2, QFont::setFamily() will no long split the family string on the comma"
|
||||
" and will keep it as a single family");
|
||||
}
|
||||
#endif
|
||||
setFamilies(splitIntoFamilies(family));
|
||||
}
|
||||
|
||||
/*!
|
||||
@ -1795,7 +1832,6 @@ bool QFont::operator<(const QFont &f) const
|
||||
if (r1.styleHint != r2.styleHint) return r1.styleHint < r2.styleHint;
|
||||
if (r1.styleStrategy != r2.styleStrategy) return r1.styleStrategy < r2.styleStrategy;
|
||||
if (r1.families != r2.families) return r1.families < r2.families;
|
||||
if (r1.family != r2.family) return r1.family < r2.family;
|
||||
if (f.d->capital != d->capital) return f.d->capital < d->capital;
|
||||
|
||||
if (f.d->letterSpacingIsAbsolute != d->letterSpacingIsAbsolute) return f.d->letterSpacingIsAbsolute < d->letterSpacingIsAbsolute;
|
||||
@ -2282,9 +2318,9 @@ void QFont::setFamilies(const QStringList &families)
|
||||
QDataStream &operator<<(QDataStream &s, const QFont &font)
|
||||
{
|
||||
if (s.version() == 1) {
|
||||
s << font.d->request.family.toLatin1();
|
||||
s << font.d->request.families.first().toLatin1();
|
||||
} else {
|
||||
s << font.d->request.family;
|
||||
s << font.d->request.families.first();
|
||||
if (s.version() >= QDataStream::Qt_5_4)
|
||||
s << font.d->request.styleName;
|
||||
}
|
||||
@ -2359,9 +2395,11 @@ QDataStream &operator>>(QDataStream &s, QFont &font)
|
||||
if (s.version() == 1) {
|
||||
QByteArray fam;
|
||||
s >> fam;
|
||||
font.d->request.family = QString::fromLatin1(fam);
|
||||
font.d->request.families = QStringList(QString::fromLatin1(fam));
|
||||
} else {
|
||||
s >> font.d->request.family;
|
||||
QString fam;
|
||||
s >> fam;
|
||||
font.d->request.families = QStringList(fam);
|
||||
if (s.version() >= QDataStream::Qt_5_4)
|
||||
s >> font.d->request.styleName;
|
||||
}
|
||||
@ -2561,7 +2599,7 @@ QString QFontInfo::family() const
|
||||
{
|
||||
QFontEngine *engine = d->engineForScript(QChar::Script_Common);
|
||||
Q_ASSERT(engine != nullptr);
|
||||
return engine->fontDef.family;
|
||||
return engine->fontDef.families.first();
|
||||
}
|
||||
|
||||
/*!
|
||||
@ -3199,7 +3237,7 @@ QDebug operator<<(QDebug stream, const QFont &font)
|
||||
|
||||
const QFont defaultFont(new QFontPrivate);
|
||||
|
||||
for (int property = QFont::FamilyResolved; property < QFont::AllPropertiesResolved; property <<= 1) {
|
||||
for (int property = QFont::SizeResolved; property < QFont::AllPropertiesResolved; property <<= 1) {
|
||||
const bool resolved = (font.resolve_mask & property) != 0;
|
||||
if (!resolved && stream.verbosity() == QDebug::MinimumVerbosity)
|
||||
continue;
|
||||
@ -3211,8 +3249,6 @@ QDebug operator<<(QDebug stream, const QFont &font)
|
||||
QDebugStateSaver saver(debug);
|
||||
|
||||
switch (property) {
|
||||
case QFont::FamilyResolved:
|
||||
debug << font.family(); break;
|
||||
case QFont::SizeResolved:
|
||||
if (font.pointSizeF() >= 0)
|
||||
debug << font.pointSizeF() << "pt";
|
||||
|
@ -168,6 +168,7 @@ public:
|
||||
|
||||
QFont();
|
||||
QFont(const QString &family, int pointSize = -1, int weight = -1, bool italic = false);
|
||||
QFont(const QStringList &families, int pointSize = -1, int weight = -1, bool italic = false);
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
||||
QFont(const QFont &font, QPaintDevice *pd);
|
||||
#endif
|
||||
|
@ -87,7 +87,6 @@ struct QFontDef
|
||||
{
|
||||
}
|
||||
|
||||
QString family;
|
||||
QStringList families;
|
||||
QString styleName;
|
||||
|
||||
@ -119,7 +118,6 @@ struct QFontDef
|
||||
&& styleHint == other.styleHint
|
||||
&& styleStrategy == other.styleStrategy
|
||||
&& ignorePitch == other.ignorePitch && fixedPitch == other.fixedPitch
|
||||
&& family == other.family
|
||||
&& families == other.families
|
||||
&& styleName == other.styleName
|
||||
&& hintingPreference == other.hintingPreference
|
||||
@ -133,7 +131,6 @@ struct QFontDef
|
||||
if (stretch != other.stretch) return stretch < other.stretch;
|
||||
if (styleHint != other.styleHint) return styleHint < other.styleHint;
|
||||
if (styleStrategy != other.styleStrategy) return styleStrategy < other.styleStrategy;
|
||||
if (family != other.family) return family < other.family;
|
||||
if (families != other.families) return families < other.families;
|
||||
if (styleName != other.styleName)
|
||||
return styleName < other.styleName;
|
||||
@ -157,7 +154,6 @@ inline size_t qHash(const QFontDef &fd, size_t seed = 0) noexcept
|
||||
fd.styleStrategy,
|
||||
fd.ignorePitch,
|
||||
fd.fixedPitch,
|
||||
fd.family,
|
||||
fd.families,
|
||||
fd.styleName,
|
||||
fd.hintingPreference);
|
||||
|
@ -480,9 +480,11 @@ struct QtFontDesc
|
||||
|
||||
static void initFontDef(const QtFontDesc &desc, const QFontDef &request, QFontDef *fontDef, bool multi)
|
||||
{
|
||||
fontDef->family = desc.family->name;
|
||||
QString family;
|
||||
family = desc.family->name;
|
||||
if (! desc.foundry->name.isEmpty() && desc.family->count > 1)
|
||||
fontDef->family += QLatin1String(" [") + desc.foundry->name + QLatin1Char(']');
|
||||
family += QLatin1String(" [") + desc.foundry->name + QLatin1Char(']');
|
||||
fontDef->families = QStringList(family);
|
||||
|
||||
if (desc.style->smoothScalable
|
||||
|| QGuiApplicationPrivate::platformIntegration()->fontDatabase()->fontsAlwaysScalable()
|
||||
@ -510,19 +512,6 @@ static QStringList familyList(const QFontDef &req)
|
||||
QStringList family_list;
|
||||
|
||||
family_list << req.families;
|
||||
if (!req.family.isEmpty()) {
|
||||
const auto list = QStringView{req.family}.split(QLatin1Char(','));
|
||||
const int numFamilies = list.size();
|
||||
family_list.reserve(numFamilies);
|
||||
for (int i = 0; i < numFamilies; ++i) {
|
||||
auto str = list.at(i).trimmed();
|
||||
if ((str.startsWith(QLatin1Char('"')) && str.endsWith(QLatin1Char('"')))
|
||||
|| (str.startsWith(QLatin1Char('\'')) && str.endsWith(QLatin1Char('\''))))
|
||||
str = str.mid(1, str.length() - 2);
|
||||
if (!family_list.contains(str))
|
||||
family_list << str.toString();
|
||||
}
|
||||
}
|
||||
// append the substitute list for each family in family_list
|
||||
for (int i = 0, size = family_list.size(); i < size; ++i)
|
||||
family_list += QFont::substitutes(family_list.at(i));
|
||||
@ -776,7 +765,7 @@ QFontEngine *loadSingleEngine(int script,
|
||||
// Also check for OpenType tables when using complex scripts
|
||||
if (Q_UNLIKELY(!engine->supportsScript(QChar::Script(script)))) {
|
||||
qWarning(" OpenType support missing for \"%s\", script %d",
|
||||
qPrintable(def.family), script);
|
||||
qPrintable(def.families.first()), script);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@ -801,7 +790,7 @@ QFontEngine *loadSingleEngine(int script,
|
||||
// Also check for OpenType tables when using complex scripts
|
||||
if (!engine->supportsScript(QChar::Script(script))) {
|
||||
qWarning(" OpenType support missing for \"%s\", script %d",
|
||||
+ qPrintable(def.family), script);
|
||||
+qPrintable(def.families.first()), script);
|
||||
if (engine->ref.loadRelaxed() == 0)
|
||||
delete engine;
|
||||
return nullptr;
|
||||
@ -1107,7 +1096,6 @@ static int match(int script, const QFontDef &request,
|
||||
|
||||
if (!matchFamilyName(family_name, test.family))
|
||||
continue;
|
||||
|
||||
test.family->ensurePopulated();
|
||||
|
||||
// Check if family is supported in the script we want
|
||||
@ -1686,7 +1674,7 @@ QFont QFontDatabase::font(const QString &family, const QString &style,
|
||||
{
|
||||
QString familyName, foundryName;
|
||||
parseFontName(family, foundryName, familyName);
|
||||
|
||||
qDebug() << family << style << familyName << foundryName;
|
||||
QMutexLocker locker(fontDatabaseMutex());
|
||||
QFontDatabasePrivate *d = QFontDatabasePrivate::ensureFontDatabase();
|
||||
|
||||
@ -1710,7 +1698,7 @@ QFont QFontDatabase::font(const QString &family, const QString &style,
|
||||
if (!s) // no styles found?
|
||||
return QGuiApplication::font();
|
||||
|
||||
QFont fnt(family, pointSize, s->key.weight);
|
||||
QFont fnt(QStringList{family}, pointSize, s->key.weight);
|
||||
fnt.setStyle((QFont::Style)s->key.style);
|
||||
if (!s->styleName.isEmpty())
|
||||
fnt.setStyleName(s->styleName);
|
||||
@ -2366,7 +2354,7 @@ QFontEngine *QFontDatabasePrivate::findFont(const QFontDef &request, int script)
|
||||
|
||||
#if defined(QT_BUILD_INTERNAL)
|
||||
// For testing purpose only, emulates an exact-matching monospace font
|
||||
if (qt_enable_test_font && request.family == QLatin1String("__Qt__Box__Engine__")) {
|
||||
if (qt_enable_test_font && request.families.first() == QLatin1String("__Qt__Box__Engine__")) {
|
||||
engine = new QTestFontEngine(request.pixelSize);
|
||||
engine->fontDef = request;
|
||||
return engine;
|
||||
@ -2387,7 +2375,7 @@ QFontEngine *QFontDatabasePrivate::findFont(const QFontDef &request, int script)
|
||||
}
|
||||
|
||||
QString family_name, foundry_name;
|
||||
const QString requestFamily = request.families.size() > 0 ? request.families.at(0) : request.family;
|
||||
const QString requestFamily = request.families.at(0);
|
||||
parseFontName(requestFamily, foundry_name, family_name);
|
||||
QtFontDesc desc;
|
||||
QList<int> blackListed;
|
||||
@ -2398,10 +2386,9 @@ QFontEngine *QFontDatabasePrivate::findFont(const QFontDef &request, int script)
|
||||
}
|
||||
if (index >= 0) {
|
||||
QFontDef fontDef = request;
|
||||
|
||||
// Don't pass empty family names to the platform font database, since it will then invoke its own matching
|
||||
// and we will be out of sync with the matched font.
|
||||
if (fontDef.families.isEmpty() && fontDef.family.isEmpty())
|
||||
if (fontDef.families.isEmpty())
|
||||
fontDef.families = QStringList(desc.family->name);
|
||||
|
||||
engine = loadEngine(script, fontDef, desc.family, desc.foundry, desc.style, desc.size);
|
||||
@ -2430,18 +2417,17 @@ QFontEngine *QFontDatabasePrivate::findFont(const QFontDef &request, int script)
|
||||
|
||||
for (int i = 0; !engine && i < fallbacks.size(); i++) {
|
||||
QFontDef def = request;
|
||||
def.families.clear();
|
||||
def.family = fallbacks.at(i);
|
||||
def.families = QStringList(fallbacks.at(i));
|
||||
QFontCache::Key key(def, script, multi ? 1 : 0);
|
||||
engine = fontCache->findEngine(key);
|
||||
if (!engine) {
|
||||
QtFontDesc desc;
|
||||
do {
|
||||
index = match(multi ? QChar::Script_Common : script, def, def.family, QLatin1String(""), &desc, blackListed);
|
||||
index = match(multi ? QChar::Script_Common : script, def, def.families.first(), QLatin1String(""), &desc, blackListed);
|
||||
if (index >= 0) {
|
||||
QFontDef loadDef = def;
|
||||
if (loadDef.families.isEmpty() && loadDef.family.isEmpty())
|
||||
loadDef.family = desc.family->name;
|
||||
if (loadDef.families.isEmpty())
|
||||
loadDef.families = QStringList(desc.family->name);
|
||||
engine = loadEngine(script, loadDef, desc.family, desc.foundry, desc.style, desc.size);
|
||||
if (engine)
|
||||
initFontDef(desc, loadDef, &engine->fontDef, multi);
|
||||
@ -2481,8 +2467,6 @@ void QFontDatabasePrivate::load(const QFontPrivate *d, int script)
|
||||
// look for the requested font in the engine data cache
|
||||
// note: fallBackFamilies are not respected in the EngineData cache key;
|
||||
// join them with the primary selection family to avoid cache misses
|
||||
if (!d->request.family.isEmpty())
|
||||
req.family = fallBackFamilies.join(QLatin1Char(','));
|
||||
if (!d->request.families.isEmpty())
|
||||
req.families = fallBackFamilies;
|
||||
|
||||
@ -2515,7 +2499,7 @@ void QFontDatabasePrivate::load(const QFontPrivate *d, int script)
|
||||
family_list << req.families.at(0);
|
||||
|
||||
// add the default family
|
||||
QString defaultFamily = QGuiApplication::font().family();
|
||||
QString defaultFamily = QGuiApplication::font().families().first();
|
||||
if (! family_list.contains(defaultFamily))
|
||||
family_list << defaultFamily;
|
||||
|
||||
|
@ -589,7 +589,8 @@ qreal QFontEngine::minRightBearing() const
|
||||
}
|
||||
|
||||
if (m_minLeftBearing == kBearingNotInitialized || m_minRightBearing == kBearingNotInitialized)
|
||||
qWarning() << "Failed to compute left/right minimum bearings for" << fontDef.family;
|
||||
qWarning() << "Failed to compute left/right minimum bearings for"
|
||||
<< fontDef.families.first();
|
||||
}
|
||||
|
||||
return m_minRightBearing;
|
||||
@ -915,12 +916,9 @@ void QFontEngine::removeGlyphFromCache(glyph_t)
|
||||
QFontEngine::Properties QFontEngine::properties() const
|
||||
{
|
||||
Properties p;
|
||||
p.postscriptName
|
||||
= QFontEngine::convertToPostscriptFontFamilyName(fontDef.family.toUtf8())
|
||||
+ '-'
|
||||
+ QByteArray::number(fontDef.style)
|
||||
+ '-'
|
||||
+ QByteArray::number(fontDef.weight);
|
||||
p.postscriptName =
|
||||
QFontEngine::convertToPostscriptFontFamilyName(fontDef.families.first().toUtf8()) + '-'
|
||||
+ QByteArray::number(fontDef.style) + '-' + QByteArray::number(fontDef.weight);
|
||||
p.ascent = ascent();
|
||||
p.descent = descent();
|
||||
p.leading = leading();
|
||||
@ -1730,7 +1728,9 @@ void QFontEngineMulti::ensureFallbackFamiliesQueried()
|
||||
if (styleHint == QFont::AnyStyle && fontDef.fixedPitch)
|
||||
styleHint = QFont::TypeWriter;
|
||||
|
||||
setFallbackFamiliesList(qt_fallbacksForFamily(fontDef.family, QFont::Style(fontDef.style), styleHint, QChar::Script(m_script)));
|
||||
setFallbackFamiliesList(qt_fallbacksForFamily(fontDef.families.first(),
|
||||
QFont::Style(fontDef.style), styleHint,
|
||||
QChar::Script(m_script)));
|
||||
}
|
||||
|
||||
void QFontEngineMulti::setFallbackFamiliesList(const QStringList &fallbackFamilies)
|
||||
@ -1744,7 +1744,7 @@ void QFontEngineMulti::setFallbackFamiliesList(const QStringList &fallbackFamili
|
||||
QFontEngine *engine = m_engines.at(0);
|
||||
engine->ref.ref();
|
||||
m_engines[1] = engine;
|
||||
m_fallbackFamilies << fontDef.family;
|
||||
m_fallbackFamilies << fontDef.families.first();
|
||||
} else {
|
||||
m_engines.resize(m_fallbackFamilies.size() + 1);
|
||||
}
|
||||
@ -1771,8 +1771,7 @@ QFontEngine *QFontEngineMulti::loadEngine(int at)
|
||||
{
|
||||
QFontDef request(fontDef);
|
||||
request.styleStrategy |= QFont::NoFontMerging;
|
||||
request.family = fallbackFamilyAt(at - 1);
|
||||
request.families = QStringList(request.family);
|
||||
request.families = QStringList(fallbackFamilyAt(at - 1));
|
||||
|
||||
// At this point, the main script of the text has already been considered
|
||||
// when fetching the list of fallback families from the database, and the
|
||||
|
@ -1255,7 +1255,7 @@ QByteArray QFontSubset::toTruetype() const
|
||||
name.copyright = QLatin1String("Fake font");
|
||||
else
|
||||
name.copyright = QLatin1String(properties.copyright);
|
||||
name.family = fontEngine->fontDef.family;
|
||||
name.family = fontEngine->fontDef.families.first();
|
||||
name.subfamily = QLatin1String("Regular"); // ######
|
||||
name.postscript_name = QLatin1String(properties.postscriptName);
|
||||
name_table = generateName(name);
|
||||
|
@ -476,7 +476,7 @@ qreal QRawFont::underlinePosition() const
|
||||
*/
|
||||
QString QRawFont::familyName() const
|
||||
{
|
||||
return d->isValid() ? d->fontEngine->fontDef.family : QString();
|
||||
return d->isValid() ? d->fontEngine->fontDef.families.first() : QString();
|
||||
}
|
||||
|
||||
/*!
|
||||
|
@ -2263,11 +2263,7 @@ QTextHtmlExporter::QTextHtmlExporter(const QTextDocument *_doc)
|
||||
|
||||
static QStringList resolvedFontFamilies(const QTextCharFormat &format)
|
||||
{
|
||||
QStringList fontFamilies = format.fontFamilies().toStringList();
|
||||
const QString mainFontFamily = format.fontFamily();
|
||||
if (!mainFontFamily.isEmpty() && !fontFamilies.contains(mainFontFamily))
|
||||
fontFamilies.append(mainFontFamily);
|
||||
return fontFamilies;
|
||||
return format.fontFamilies().toStringList();
|
||||
}
|
||||
|
||||
/*!
|
||||
|
@ -356,9 +356,6 @@ void QTextFormatPrivate::recalcFont() const
|
||||
|
||||
for (int i = 0; i < props.count(); ++i) {
|
||||
switch (props.at(i).key) {
|
||||
case QTextFormat::FontFamily:
|
||||
f.setFamily(props.at(i).value.toString());
|
||||
break;
|
||||
case QTextFormat::FontFamilies:
|
||||
f.setFamilies(props.at(i).value.toStringList());
|
||||
break;
|
||||
@ -461,6 +458,12 @@ Q_GUI_EXPORT QDataStream &operator<<(QDataStream &stream, const QTextFormat &fmt
|
||||
properties[QTextFormat::OldTextUnderlineColor] = it.value();
|
||||
properties.erase(it);
|
||||
}
|
||||
|
||||
it = properties.find(QTextFormat::FontFamilies);
|
||||
if (it != properties.end()) {
|
||||
properties[QTextFormat::FontFamily] = QVariant(it.value().toStringList().first());
|
||||
properties.erase(it);
|
||||
}
|
||||
}
|
||||
|
||||
stream << fmt.format_type << properties;
|
||||
@ -486,6 +489,8 @@ Q_GUI_EXPORT QDataStream &operator>>(QDataStream &stream, QTextFormat &fmt)
|
||||
key = QTextFormat::FontStretch;
|
||||
else if (key == QTextFormat::OldTextUnderlineColor)
|
||||
key = QTextFormat::TextUnderlineColor;
|
||||
else if (key == QTextFormat::FontFamily)
|
||||
key = QTextFormat::FontFamilies;
|
||||
fmt.d->insertProperty(key, it.value());
|
||||
}
|
||||
|
||||
@ -605,7 +610,7 @@ Q_GUI_EXPORT QDataStream &operator>>(QDataStream &stream, QTextFormat &fmt)
|
||||
|
||||
Character properties
|
||||
|
||||
\value FontFamily
|
||||
\value FontFamily e{This property has been deprecated.} Use QTextFormat::FontFamilies instead.
|
||||
\value FontFamilies
|
||||
\value FontStyleName
|
||||
\value FontPointSize
|
||||
@ -2041,8 +2046,6 @@ void QTextCharFormat::setFont(const QFont &font, FontPropertiesInheritanceBehavi
|
||||
const uint mask = behavior == FontPropertiesAll ? uint(QFont::AllPropertiesResolved)
|
||||
: font.resolveMask();
|
||||
|
||||
if (mask & QFont::FamilyResolved)
|
||||
setFontFamily(font.family());
|
||||
if (mask & QFont::FamiliesResolved)
|
||||
setFontFamilies(font.families());
|
||||
if (mask & QFont::StyleNameResolved)
|
||||
|
@ -192,7 +192,9 @@ public:
|
||||
FontStyleName = 0x1FE8,
|
||||
FontLetterSpacingType = 0x1FE9,
|
||||
FontStretch = 0x1FEA,
|
||||
#if QT_DEPRECATED_SINCE(6, 0)
|
||||
FontFamily = 0x2000,
|
||||
#endif
|
||||
FontPointSize = 0x2001,
|
||||
FontSizeAdjustment = 0x2002,
|
||||
FontSizeIncrement = FontSizeAdjustment, // old name, compat
|
||||
@ -454,10 +456,12 @@ public:
|
||||
void setFont(const QFont &font, FontPropertiesInheritanceBehavior behavior = FontPropertiesAll);
|
||||
QFont font() const;
|
||||
|
||||
inline void setFontFamily(const QString &family)
|
||||
{ setProperty(FontFamily, family); }
|
||||
inline QString fontFamily() const
|
||||
{ return stringProperty(FontFamily); }
|
||||
#if QT_DEPRECATED_SINCE(6, 0)
|
||||
QT_DEPRECATED_VERSION_X_6_0("Use setFontFamilies instead") inline void setFontFamily(const QString &family)
|
||||
{ setProperty(FontFamilies, QVariant(QStringList(family))); }
|
||||
QT_DEPRECATED_VERSION_X_6_0("Use fontFamilies instead") inline QString fontFamily() const
|
||||
{ return property(FontFamilies).toStringList().first(); }
|
||||
#endif
|
||||
|
||||
inline void setFontFamilies(const QStringList &families)
|
||||
{ setProperty(FontFamilies, QVariant(families)); }
|
||||
|
@ -1585,9 +1585,8 @@ void QTextHtmlParser::applyAttributes(const QStringList &attributes)
|
||||
for (const QString &family : values)
|
||||
families << family.trimmed();
|
||||
node->charFormat.setFontFamilies(families);
|
||||
node->charFormat.setFontFamily(families.at(0));
|
||||
} else {
|
||||
node->charFormat.setFontFamily(value);
|
||||
node->charFormat.setFontFamilies(QStringList(value));
|
||||
}
|
||||
} else if (key == QLatin1String("color")) {
|
||||
QColor c; c.setNamedColor(value);
|
||||
@ -2064,7 +2063,7 @@ QList<QCss::Declaration> standardDeclarationForNode(const QTextHtmlParserNode &n
|
||||
decl.d->propertyId = QCss::FontFamily;
|
||||
QList<QCss::Value> values;
|
||||
val.type = QCss::Value::String;
|
||||
val.variant = QFontDatabase::systemFont(QFontDatabase::FixedFont).family();
|
||||
val.variant = QFontDatabase::systemFont(QFontDatabase::FixedFont).families().first();
|
||||
values << val;
|
||||
decl.d->values = values;
|
||||
decl.d->inheritable = true;
|
||||
|
@ -428,8 +428,9 @@ int QTextMarkdownImporter::cbEnterSpan(int spanType, void *det)
|
||||
break;
|
||||
}
|
||||
m_spanFormatStack.push(charFmt);
|
||||
qCDebug(lcMD) << spanType << "setCharFormat" << charFmt.font().family() << charFmt.fontWeight()
|
||||
<< (charFmt.fontItalic() ? "italic" : "") << charFmt.foreground().color().name();
|
||||
qCDebug(lcMD) << spanType << "setCharFormat" << charFmt.font().families().first()
|
||||
<< charFmt.fontWeight() << (charFmt.fontItalic() ? "italic" : "")
|
||||
<< charFmt.foreground().color().name();
|
||||
m_cursor->setCharFormat(charFmt);
|
||||
return 0; // no error
|
||||
}
|
||||
@ -444,8 +445,9 @@ int QTextMarkdownImporter::cbLeaveSpan(int spanType, void *detail)
|
||||
charFmt = m_spanFormatStack.top();
|
||||
}
|
||||
m_cursor->setCharFormat(charFmt);
|
||||
qCDebug(lcMD) << spanType << "setCharFormat" << charFmt.font().family() << charFmt.fontWeight()
|
||||
<< (charFmt.fontItalic() ? "italic" : "") << charFmt.foreground().color().name();
|
||||
qCDebug(lcMD) << spanType << "setCharFormat" << charFmt.font().families().first()
|
||||
<< charFmt.fontWeight() << (charFmt.fontItalic() ? "italic" : "")
|
||||
<< charFmt.foreground().color().name();
|
||||
if (spanType == int(MD_SPAN_IMG))
|
||||
m_imageSpan = false;
|
||||
return 0; // no error
|
||||
|
@ -973,7 +973,7 @@ void QFontconfigDatabase::setupFontEngine(QFontEngineFT *engine, const QFontDef
|
||||
|
||||
FcValue value;
|
||||
value.type = FcTypeString;
|
||||
QByteArray cs = fontDef.family.toUtf8();
|
||||
QByteArray cs = fontDef.families.first().toUtf8();
|
||||
value.u.s = (const FcChar8 *)cs.data();
|
||||
FcPatternAdd(pattern,FC_FAMILY,value,true);
|
||||
|
||||
|
@ -414,8 +414,8 @@ void QWindowsDirectWriteFontDatabase::populateFontDatabase()
|
||||
bool hasDefaultLocale = GetUserDefaultLocaleName(defaultLocale, LOCALE_NAME_MAX_LENGTH) != 0;
|
||||
wchar_t englishLocale[] = L"en-us";
|
||||
|
||||
QString defaultFontName = defaultFont().family();
|
||||
QString systemDefaultFontName = systemDefaultFont().family();
|
||||
const QString defaultFontName = defaultFont().families().first();
|
||||
const QString systemDefaultFontName = systemDefaultFont().families().first();
|
||||
|
||||
IDWriteFontCollection *fontCollection;
|
||||
if (SUCCEEDED(data()->directWriteFactory->GetSystemFontCollection(&fontCollection))) {
|
||||
|
@ -162,7 +162,7 @@ QDebug operator<<(QDebug d, const QFontDef &def)
|
||||
QDebugStateSaver saver(d);
|
||||
d.nospace();
|
||||
d.noquote();
|
||||
d << "QFontDef(Family=\"" << def.family << '"';
|
||||
d << "QFontDef(Family=\"" << def.families.first() << '"';
|
||||
if (!def.styleName.isEmpty())
|
||||
d << ", stylename=" << def.styleName;
|
||||
d << ", pointsize=" << def.pointSize << ", pixelsize=" << def.pixelSize
|
||||
@ -628,6 +628,8 @@ static int QT_WIN_CALLBACK storeFont(const LOGFONT *logFont, const TEXTMETRIC *t
|
||||
{
|
||||
const ENUMLOGFONTEX *f = reinterpret_cast<const ENUMLOGFONTEX *>(logFont);
|
||||
const QString familyName = QString::fromWCharArray(f->elfLogFont.lfFaceName);
|
||||
if (familyName == QLatin1String("Lucida Calligraphy"))
|
||||
qDebug("BP");
|
||||
const QString styleName = QString::fromWCharArray(f->elfStyle);
|
||||
|
||||
// NEWTEXTMETRICEX (passed for TT fonts) is a NEWTEXTMETRIC, which according
|
||||
@ -730,7 +732,7 @@ void QWindowsFontDatabase::populateFontDatabase()
|
||||
EnumFontFamiliesEx(dummy, &lf, populateFontFamilies, 0, 0);
|
||||
ReleaseDC(0, dummy);
|
||||
// Work around EnumFontFamiliesEx() not listing the system font.
|
||||
QString systemDefaultFamily = QWindowsFontDatabase::systemDefaultFont().family();
|
||||
const QString systemDefaultFamily = QWindowsFontDatabase::systemDefaultFont().families().first();
|
||||
if (QPlatformFontDatabase::resolveFontFamilyAlias(systemDefaultFamily) == systemDefaultFamily)
|
||||
QPlatformFontDatabase::registerFontFamily(systemDefaultFamily);
|
||||
addDefaultEUDCFont();
|
||||
@ -807,7 +809,7 @@ QT_WARNING_POP
|
||||
qWarning("%s: AddFontMemResourceEx failed", __FUNCTION__);
|
||||
} else {
|
||||
QFontDef request;
|
||||
request.family = uniqueFamilyName;
|
||||
request.families = QStringList(uniqueFamilyName);
|
||||
request.pixelSize = pixelSize;
|
||||
request.styleStrategy = QFont::PreferMatch;
|
||||
request.hintingPreference = hintingPreference;
|
||||
@ -818,9 +820,9 @@ QT_WARNING_POP
|
||||
data());
|
||||
|
||||
if (fontEngine) {
|
||||
if (request.family != fontEngine->fontDef.family) {
|
||||
qWarning("%s: Failed to load font. Got fallback instead: %s",
|
||||
__FUNCTION__, qPrintable(fontEngine->fontDef.family));
|
||||
if (request.families != fontEngine->fontDef.families) {
|
||||
qWarning("%s: Failed to load font. Got fallback instead: %s", __FUNCTION__,
|
||||
qPrintable(fontEngine->fontDef.families.first()));
|
||||
if (fontEngine->ref.loadRelaxed() == 0)
|
||||
delete fontEngine;
|
||||
fontEngine = 0;
|
||||
@ -831,12 +833,12 @@ QT_WARNING_POP
|
||||
switch (fontEngine->type()) {
|
||||
case QFontEngine::Win:
|
||||
static_cast<QWindowsFontEngine *>(fontEngine)->setUniqueFamilyName(uniqueFamilyName);
|
||||
fontEngine->fontDef.family = actualFontName;
|
||||
fontEngine->fontDef.families = QStringList(actualFontName);
|
||||
break;
|
||||
#if QT_CONFIG(directwrite) && QT_CONFIG(direct2d)
|
||||
case QFontEngine::DirectWrite:
|
||||
static_cast<QWindowsFontEngineDirectWrite *>(fontEngine)->setUniqueFamilyName(uniqueFamilyName);
|
||||
fontEngine->fontDef.family = actualFontName;
|
||||
fontEngine->fontDef.families = QStringList(actualFontName);
|
||||
break;
|
||||
#endif // directwrite && direct2d
|
||||
|
||||
@ -1197,9 +1199,11 @@ QFontEngine *QWindowsFontDatabase::createEngine(const QFontDef &request, const Q
|
||||
}
|
||||
#endif // direct2d
|
||||
useDw = useDw || useDirectWrite(hintingPreference, fam, isColorFont);
|
||||
qCDebug(lcQpaFonts) << __FUNCTION__ << request.family << request.pointSize
|
||||
<< "pt" << "hintingPreference=" << hintingPreference << "color=" << isColorFont
|
||||
<< dpi << "dpi" << "useDirectWrite=" << useDw;
|
||||
qCDebug(lcQpaFonts)
|
||||
<< __FUNCTION__ << request.families.first() << request.pointSize << "pt"
|
||||
<< "hintingPreference=" << hintingPreference << "color=" << isColorFont
|
||||
<< dpi << "dpi"
|
||||
<< "useDirectWrite=" << useDw;
|
||||
if (useDw) {
|
||||
QWindowsFontEngineDirectWrite *fedw = new QWindowsFontEngineDirectWrite(directWriteFontFace,
|
||||
request.pixelSize,
|
||||
@ -1209,7 +1213,7 @@ QFontEngine *QWindowsFontDatabase::createEngine(const QFontDef &request, const Q
|
||||
GetTextFace(data->hdc, 64, n);
|
||||
|
||||
QFontDef fontDef = request;
|
||||
fontDef.family = QString::fromWCharArray(n);
|
||||
fontDef.families = QStringList(QString::fromWCharArray(n));
|
||||
|
||||
if (isColorFont)
|
||||
fedw->glyphFormat = QFontEngine::Format_ARGB;
|
||||
@ -1230,7 +1234,7 @@ QFontEngine *QWindowsFontDatabase::createEngine(const QFontDef &request, const Q
|
||||
#endif // directwrite direct2d
|
||||
|
||||
if (!fe) {
|
||||
QWindowsFontEngine *few = new QWindowsFontEngine(request.family, lf, data);
|
||||
QWindowsFontEngine *few = new QWindowsFontEngine(request.families.first(), lf, data);
|
||||
if (preferClearTypeAA)
|
||||
few->glyphFormat = QFontEngine::Format_A32;
|
||||
few->initFontInfo(request, dpi);
|
||||
|
@ -398,7 +398,7 @@ void QWindowsFontDatabaseFT::populateFontDatabase()
|
||||
EnumFontFamiliesEx(dummy, &lf, populateFontFamilies, 0, 0);
|
||||
ReleaseDC(0, dummy);
|
||||
// Work around EnumFontFamiliesEx() not listing the system font
|
||||
QString systemDefaultFamily = QWindowsFontDatabase::systemDefaultFont().family();
|
||||
const QString systemDefaultFamily = QWindowsFontDatabase::systemDefaultFont().families().first();
|
||||
if (QPlatformFontDatabase::resolveFontFamilyAlias(systemDefaultFamily) == systemDefaultFamily)
|
||||
QPlatformFontDatabase::registerFontFamily(systemDefaultFamily);
|
||||
}
|
||||
@ -406,7 +406,7 @@ void QWindowsFontDatabaseFT::populateFontDatabase()
|
||||
QFontEngine * QWindowsFontDatabaseFT::fontEngine(const QFontDef &fontDef, void *handle)
|
||||
{
|
||||
QFontEngine *fe = QFreeTypeFontDatabase::fontEngine(fontDef, handle);
|
||||
qCDebug(lcQpaFonts) << __FUNCTION__ << "FONTDEF" << fontDef.family << fe << handle;
|
||||
qCDebug(lcQpaFonts) << __FUNCTION__ << "FONTDEF" << fontDef.families.first() << fe << handle;
|
||||
return fe;
|
||||
}
|
||||
|
||||
|
@ -707,7 +707,7 @@ LOGFONT QWindowsFontDatabaseBase::fontDefToLOGFONT(const QFontDef &request, cons
|
||||
|
||||
QString fam = faceName;
|
||||
if (fam.isEmpty())
|
||||
fam = request.families.size() > 0 ? request.families.at(0) : request.family;
|
||||
fam = request.families.first();
|
||||
if (Q_UNLIKELY(fam.size() >= LF_FACESIZE)) {
|
||||
qCritical("%s: Family name '%s' is too long.", __FUNCTION__, qPrintable(fam));
|
||||
fam.truncate(LF_FACESIZE - 1);
|
||||
@ -833,7 +833,7 @@ QFontEngine *QWindowsFontDatabaseBase::fontEngine(const QByteArray &fontData, qr
|
||||
// Get font family from font data
|
||||
EmbeddedFont font(fontData);
|
||||
font.updateFromOS2Table(fontEngine);
|
||||
fontEngine->fontDef.family = font.familyName();
|
||||
fontEngine->fontDef.families = QStringList(font.familyName());
|
||||
fontEngine->fontDef.hintingPreference = hintingPreference;
|
||||
|
||||
directWriteFontFace->Release();
|
||||
|
@ -1145,9 +1145,9 @@ QImage QWindowsFontEngine::alphaRGBMapForGlyph(glyph_t glyph, QFixed, const QTra
|
||||
QFontEngine *QWindowsFontEngine::cloneWithSize(qreal pixelSize) const
|
||||
{
|
||||
QFontDef request = fontDef;
|
||||
QString actualFontName = request.family;
|
||||
QString actualFontName = request.families.first();
|
||||
if (!uniqueFamilyName.isEmpty())
|
||||
request.family = uniqueFamilyName;
|
||||
request.families = QStringList(uniqueFamilyName);
|
||||
request.pixelSize = pixelSize;
|
||||
const QString faceName = QString::fromWCharArray(m_logfont.lfFaceName);
|
||||
|
||||
@ -1156,7 +1156,7 @@ QFontEngine *QWindowsFontEngine::cloneWithSize(qreal pixelSize) const
|
||||
QWindowsFontDatabase::defaultVerticalDPI(),
|
||||
m_fontEngineData);
|
||||
if (fontEngine) {
|
||||
fontEngine->fontDef.family = actualFontName;
|
||||
fontEngine->fontDef.families = QStringList(actualFontName);
|
||||
if (!uniqueFamilyName.isEmpty()) {
|
||||
static_cast<QWindowsFontEngine *>(fontEngine)->setUniqueFamilyName(uniqueFamilyName);
|
||||
if (QPlatformIntegration *pi = QGuiApplicationPrivate::platformIntegration()) {
|
||||
@ -1181,7 +1181,7 @@ void QWindowsFontEngine::initFontInfo(const QFontDef &request,
|
||||
SelectObject(dc, hfont);
|
||||
wchar_t n[64];
|
||||
GetTextFace(dc, 64, n);
|
||||
fontDef.family = QString::fromWCharArray(n);
|
||||
fontDef.families = QStringList(QString::fromWCharArray(n));
|
||||
fontDef.fixedPitch = !(tm.tmPitchAndFamily & TMPF_FIXED_PITCH);
|
||||
if (fontDef.pointSize < 0) {
|
||||
fontDef.pointSize = fontDef.pixelSize * 72. / dpi;
|
||||
|
@ -94,7 +94,7 @@ void QCocoaMenu::setMinimumWidth(int width)
|
||||
void QCocoaMenu::setFont(const QFont &font)
|
||||
{
|
||||
if (font.resolveMask()) {
|
||||
NSFont *customMenuFont = [NSFont fontWithName:font.family().toNSString()
|
||||
NSFont *customMenuFont = [NSFont fontWithName:font.families().first().toNSString()
|
||||
size:font.pointSize()];
|
||||
m_nativeMenu.font = customMenuFont;
|
||||
}
|
||||
|
@ -573,7 +573,7 @@ static QFont qt_fontFromString(const QString &name)
|
||||
|
||||
QString family = QString::fromUtf8(pango_font_description_get_family(desc));
|
||||
if (!family.isEmpty())
|
||||
font.setFamily(family);
|
||||
font.setFamilies(QStringList{family});
|
||||
|
||||
font.setWeight(QFont::Weight(pango_font_description_get_weight(desc)));
|
||||
|
||||
|
@ -2301,7 +2301,7 @@ void QWindowsVistaStyle::polish(QWidget *widget)
|
||||
#if QT_CONFIG(commandlinkbutton)
|
||||
else if (qobject_cast<QCommandLinkButton*>(widget)) {
|
||||
QFont buttonFont = widget->font();
|
||||
buttonFont.setFamily(QLatin1String("Segoe UI"));
|
||||
buttonFont.setFamilies(QStringList{QLatin1String("Segoe UI")});
|
||||
widget->setFont(buttonFont);
|
||||
}
|
||||
#endif // QT_CONFIG(commandlinkbutton)
|
||||
@ -2386,7 +2386,7 @@ void QWindowsVistaStyle::unpolish(QWidget *widget)
|
||||
else if (qobject_cast<QCommandLinkButton*>(widget)) {
|
||||
QFont font = QApplication::font("QCommandLinkButton");
|
||||
QFont widgetFont = widget->font();
|
||||
widgetFont.setFamily(font.family()); //Only family set by polish
|
||||
widgetFont.setFamilies(font.families()); //Only family set by polish
|
||||
widget->setFont(widgetFont);
|
||||
}
|
||||
#endif // QT_CONFIG(commandlinkbutton)
|
||||
|
@ -1602,8 +1602,8 @@ QString WriteInitialization::writeFontProperties(const DomFont *f)
|
||||
m_output << m_indent << language::stackVariable("QFont", fontName)
|
||||
<< language::eol;
|
||||
if (f->hasElementFamily() && !f->elementFamily().isEmpty()) {
|
||||
m_output << m_indent << fontName << ".setFamily("
|
||||
<< language::qstring(f->elementFamily(), m_dindent) << ")" << language::eol;
|
||||
m_output << m_indent << fontName << ".setFamilies(QStringList{"
|
||||
<< language::qstring(f->elementFamily(), m_dindent) << "})" << language::eol;
|
||||
}
|
||||
if (f->hasElementPointSize() && f->elementPointSize() > 0) {
|
||||
m_output << m_indent << fontName << ".setPointSize(" << f->elementPointSize()
|
||||
|
@ -850,7 +850,7 @@ QString QAccessibleTextWidget::attributes(int offset, int *startOffset, int *end
|
||||
const QFont charFormatFont = charFormat.font();
|
||||
|
||||
AttributeFormatter attrs;
|
||||
QString family = charFormatFont.family();
|
||||
QString family = charFormatFont.families().first();
|
||||
if (!family.isEmpty()) {
|
||||
family = family.replace(u'\\', QLatin1String("\\\\"));
|
||||
family = family.replace(u':', QLatin1String("\\:"));
|
||||
|
@ -534,7 +534,7 @@ void QFontDialogPrivate::updateFamilies()
|
||||
match_t type = MATCH_NONE;
|
||||
if (bestFamilyType <= MATCH_NONE && familyName2 == QStringLiteral("helvetica"))
|
||||
type = MATCH_LAST_RESORT;
|
||||
if (bestFamilyType <= MATCH_LAST_RESORT && familyName2 == f.family())
|
||||
if (bestFamilyType <= MATCH_LAST_RESORT && familyName2 == f.families().first())
|
||||
type = MATCH_APP;
|
||||
// ### add fallback for writingSystem
|
||||
if (type != MATCH_NONE) {
|
||||
@ -804,7 +804,7 @@ void QFontDialog::changeEvent(QEvent *e)
|
||||
void QFontDialog::setCurrentFont(const QFont &font)
|
||||
{
|
||||
Q_D(QFontDialog);
|
||||
d->family = font.family();
|
||||
d->family = font.families().first();
|
||||
d->style = QFontDatabase::styleString(font);
|
||||
d->size = font.pointSize();
|
||||
if (d->size == -1) {
|
||||
|
@ -134,8 +134,8 @@ static QFontDatabase::WritingSystem writingSystemFromLocale()
|
||||
|
||||
static QFontDatabase::WritingSystem writingSystemForFont(const QFont &font, bool *hasLatin)
|
||||
{
|
||||
QList<QFontDatabase::WritingSystem> writingSystems = QFontDatabase::writingSystems(font.family());
|
||||
// qDebug() << font.family() << writingSystems;
|
||||
QList<QFontDatabase::WritingSystem> writingSystems = QFontDatabase::writingSystems(font.families().first());
|
||||
// qDebug() << font.families().first() << writingSystems;
|
||||
|
||||
// this just confuses the algorithm below. Vietnamese is Latin with lots of special chars
|
||||
writingSystems.removeOne(QFontDatabase::Vietnamese);
|
||||
@ -213,7 +213,7 @@ void QFontFamilyDelegate::paint(QPainter *painter,
|
||||
QFont font(option.font);
|
||||
font.setPointSize(QFontInfo(font).pointSize() * 3 / 2);
|
||||
QFont font2 = font;
|
||||
font2.setFamily(text);
|
||||
font2.setFamilies(QStringList{text});
|
||||
|
||||
bool hasLatin;
|
||||
QFontDatabase::WritingSystem system = writingSystemForFont(font2, &hasLatin);
|
||||
@ -286,7 +286,7 @@ QSize QFontFamilyDelegate::sizeHint(const QStyleOptionViewItem &option,
|
||||
{
|
||||
QString text = index.data(Qt::DisplayRole).toString();
|
||||
QFont font(option.font);
|
||||
// font.setFamily(text);
|
||||
// font.setFamilies(QStringList{text});
|
||||
font.setPointSize(QFontInfo(font).pointSize() * 3/2);
|
||||
QFontMetrics fontMetrics(font);
|
||||
return QSize(fontMetrics.horizontalAdvance(text), fontMetrics.height());
|
||||
@ -367,8 +367,8 @@ void QFontComboBoxPrivate::_q_updateModel()
|
||||
void QFontComboBoxPrivate::_q_currentChanged(const QString &text)
|
||||
{
|
||||
Q_Q(QFontComboBox);
|
||||
if (currentFont.family() != text) {
|
||||
currentFont.setFamily(text);
|
||||
if (currentFont.families().first() != text) {
|
||||
currentFont.setFamilies(QStringList{text});
|
||||
emit q->currentFontChanged(currentFont);
|
||||
}
|
||||
}
|
||||
|
@ -311,10 +311,11 @@ void tst_QFont::resolve()
|
||||
QCOMPARE(font6.families(), fontFamilies);
|
||||
|
||||
QFont font7, font8;
|
||||
// This will call setFamilies() directly now
|
||||
font7.setFamily(QLatin1String("Helvetica"));
|
||||
font8.setFamilies(fontFamilies);
|
||||
font7 = font7.resolve(font8);
|
||||
QCOMPARE(font7.families(), QStringList({"Helvetica", "Arial"}));
|
||||
QCOMPARE(font7.families(), QStringList({"Helvetica"}));
|
||||
QCOMPARE(font7.family(), "Helvetica");
|
||||
}
|
||||
|
||||
@ -710,6 +711,7 @@ void tst_QFont::sharing()
|
||||
|
||||
void tst_QFont::familyNameWithCommaQuote_data()
|
||||
{
|
||||
QTest::addColumn<QString>("enteredFamilyName");
|
||||
QTest::addColumn<QString>("familyName");
|
||||
QTest::addColumn<QString>("chosenFamilyName");
|
||||
|
||||
@ -717,15 +719,16 @@ void tst_QFont::familyNameWithCommaQuote_data()
|
||||
if (standardFont.isEmpty())
|
||||
QSKIP("No default font available on the system");
|
||||
const QString weirdFont(QLatin1String("'My, weird'' font name',"));
|
||||
const QString bogusFont(QLatin1String("BogusFont"));
|
||||
const QString commaSeparated(standardFont + QLatin1String(",Times New Roman"));
|
||||
const QString commaSeparatedWeird(weirdFont + QLatin1String(",") + standardFont);
|
||||
const QString commaSeparatedBogus(QLatin1String("BogusFont,") + standardFont);
|
||||
const QString commaSeparatedBogus(bogusFont + QLatin1String(",") + standardFont);
|
||||
|
||||
QTest::newRow("standard") << standardFont << standardFont;
|
||||
QTest::newRow("weird") << weirdFont << weirdFont;
|
||||
QTest::newRow("commaSeparated") << commaSeparated << standardFont;
|
||||
QTest::newRow("commaSeparatedWeird") << commaSeparatedWeird << weirdFont;
|
||||
QTest::newRow("commaSeparatedBogus") << commaSeparatedBogus << standardFont;
|
||||
QTest::newRow("standard") << standardFont << standardFont << standardFont;
|
||||
QTest::newRow("weird") << weirdFont << QString("'My") << standardFont;
|
||||
QTest::newRow("commaSeparated") << commaSeparated << standardFont << standardFont;
|
||||
QTest::newRow("commaSeparatedWeird") << commaSeparatedWeird << QString("'My") << standardFont;
|
||||
QTest::newRow("commaSeparatedBogus") << commaSeparatedBogus << bogusFont << standardFont;
|
||||
}
|
||||
|
||||
void tst_QFont::familyNameWithCommaQuote()
|
||||
@ -804,8 +807,8 @@ void tst_QFont::setFamiliesAndFamily()
|
||||
|
||||
QVERIFY(weirdFontId != -1);
|
||||
QFont f;
|
||||
f.setFamilies(families);
|
||||
f.setFamily(family);
|
||||
f.setFamilies(families);
|
||||
QCOMPARE(QFontInfo(f).family(), chosenFamilyName);
|
||||
|
||||
QFontDatabase::removeApplicationFont(weirdFontId);
|
||||
|
@ -72,23 +72,29 @@ tst_QFontCache::~tst_QFontCache()
|
||||
void tst_QFontCache::engineData_data()
|
||||
{
|
||||
QTest::addColumn<QString>("family");
|
||||
QTest::addColumn<QString>("cacheKey");
|
||||
QTest::addColumn<QStringList>("cacheKey");
|
||||
|
||||
QTest::newRow("unquoted-family-name") << QString("Times New Roman") << QString("Times New Roman");
|
||||
QTest::newRow("quoted-family-name") << QString("'Times New Roman'") << QString("Times New Roman");
|
||||
QTest::newRow("invalid") << QString("invalid") << QString("invalid");
|
||||
QTest::newRow("multiple") << QString("invalid, Times New Roman") << QString("invalid,Times New Roman");
|
||||
QTest::newRow("multiple spaces") << QString("invalid, Times New Roman ") << QString("invalid,Times New Roman");
|
||||
QTest::newRow("multiple spaces quotes") << QString("'invalid', Times New Roman ") << QString("invalid,Times New Roman");
|
||||
QTest::newRow("multiple2") << QString("invalid, Times New Roman , foobar, 'baz'") << QString("invalid,Times New Roman,foobar,baz");
|
||||
QTest::newRow("invalid spaces") << QString("invalid spaces, Times New Roman ") << QString("invalid spaces,Times New Roman");
|
||||
QTest::newRow("invalid spaces quotes") << QString("'invalid spaces', 'Times New Roman' ") << QString("invalid spaces,Times New Roman");
|
||||
QTest::newRow("unquoted-family-name") << QString("Times New Roman") << QStringList({"Times New Roman"});
|
||||
QTest::newRow("quoted-family-name") << QString("'Times New Roman'") << QStringList({"Times New Roman"});
|
||||
QTest::newRow("invalid") << QString("invalid") << QStringList({"invalid"});
|
||||
QTest::newRow("multiple") << QString("invalid, Times New Roman")
|
||||
<< QStringList({"invalid", "Times New Roman"});
|
||||
QTest::newRow("multiple spaces") << QString("invalid, Times New Roman ")
|
||||
<< QStringList({"invalid", "Times New Roman"});
|
||||
QTest::newRow("multiple spaces quotes") << QString("'invalid', Times New Roman ")
|
||||
<< QStringList({"invalid", "Times New Roman"});
|
||||
QTest::newRow("multiple2") << QString("invalid, Times New Roman , foobar, 'baz'")
|
||||
<< QStringList({"invalid", "Times New Roman", "foobar", "baz"});
|
||||
QTest::newRow("invalid spaces") << QString("invalid spaces, Times New Roman ")
|
||||
<< QStringList({"invalid spaces", "Times New Roman"});
|
||||
QTest::newRow("invalid spaces quotes") << QString("'invalid spaces', 'Times New Roman' ")
|
||||
<< QStringList({"invalid spaces", "Times New Roman"});
|
||||
}
|
||||
|
||||
void tst_QFontCache::engineData()
|
||||
{
|
||||
QFETCH(QString, family);
|
||||
QFETCH(QString, cacheKey);
|
||||
QFETCH(QStringList, cacheKey);
|
||||
|
||||
QFont f(family);
|
||||
f.exactMatch(); // loads engine
|
||||
@ -104,7 +110,7 @@ void tst_QFontCache::engineData()
|
||||
if (req.pointSize < 0)
|
||||
req.pointSize = req.pixelSize*72.0/d->dpi;
|
||||
|
||||
req.family = cacheKey;
|
||||
req.families = cacheKey;
|
||||
|
||||
QFontEngineData *engineData = QFontCache::instance()->findEngineData(req);
|
||||
|
||||
|
@ -3570,13 +3570,13 @@ void tst_QTextDocument::mergeFontFamilies()
|
||||
cursor.setPosition(QByteArray("Hello World").length(), QTextCursor::KeepAnchor);
|
||||
cursor.mergeCharFormat(newFormat);
|
||||
|
||||
QVERIFY(td.toHtml().contains(QLatin1String("font-family:'MS Shell Dlg 2','Jokerman';")));
|
||||
QVERIFY(td.toHtml().contains(QLatin1String("font-family:'Jokerman';")));
|
||||
|
||||
QTextCharFormat newFormatFamilies;
|
||||
newFormatFamilies.setFontFamilies({ QLatin1String("Arial"), QLatin1String("Helvetica") });
|
||||
cursor.mergeCharFormat(newFormatFamilies);
|
||||
|
||||
QVERIFY(td.toHtml().contains(QLatin1String("font-family:'Arial','Helvetica','Jokerman'")));
|
||||
QVERIFY(td.toHtml().contains(QLatin1String("font-family:'Arial','Helvetica'")));
|
||||
|
||||
newFormatFamilies.setFontFamilies({ QLatin1String("Arial"), QLatin1String("Jokerman"), QLatin1String("Helvetica") });
|
||||
cursor.mergeCharFormat(newFormatFamilies);
|
||||
|
@ -1661,19 +1661,22 @@ void tst_QTextDocumentFragment::html_cssShorthandFont()
|
||||
const char html[] = "<span style=\"font: 50px sans-serif\">Foo</span>";
|
||||
setHtml(html);
|
||||
QCOMPARE(cursor.charFormat().property(QTextFormat::FontPixelSize).toInt(), 50);
|
||||
QCOMPARE(cursor.charFormat().property(QTextFormat::FontFamily).toString(), QString("sans-serif"));
|
||||
QCOMPARE(cursor.charFormat().property(QTextFormat::FontFamilies).toStringList(),
|
||||
QStringList{"sans-serif"});
|
||||
}
|
||||
{
|
||||
const char html[] = "<span style=\"font: 50pt sans-serif\">Foo</span>";
|
||||
setHtml(html);
|
||||
QCOMPARE(cursor.charFormat().property(QTextFormat::FontPointSize).toInt(), 50);
|
||||
QCOMPARE(cursor.charFormat().property(QTextFormat::FontFamily).toString(), QString("sans-serif"));
|
||||
QCOMPARE(cursor.charFormat().property(QTextFormat::FontFamilies).toStringList(),
|
||||
QStringList{"sans-serif"});
|
||||
}
|
||||
{
|
||||
const char html[] = "<span style='font:7.0pt \"Times New Roman\"'>Foo</span>";
|
||||
setHtml(html);
|
||||
QCOMPARE(cursor.charFormat().property(QTextFormat::FontPointSize).toInt(), 7);
|
||||
QCOMPARE(cursor.charFormat().property(QTextFormat::FontFamily).toString(), QString("Times New Roman"));
|
||||
QCOMPARE(cursor.charFormat().property(QTextFormat::FontFamilies).toStringList(),
|
||||
QStringList{"Times New Roman"});
|
||||
}
|
||||
{
|
||||
const char html[] = "<span style='font:bold 7.0pt'>Foo</span>";
|
||||
|
@ -693,14 +693,17 @@ void tst_QTextFormat::dataStreamCompatibility()
|
||||
QTextCharFormat format;
|
||||
format.setFontStretch(42);
|
||||
format.setFontLetterSpacingType(QFont::AbsoluteSpacing);
|
||||
format.setFontFamily(QLatin1String("Arial"));
|
||||
|
||||
// Sanity check
|
||||
{
|
||||
QMap<int, QVariant> properties = format.properties();
|
||||
QVERIFY(properties.contains(QTextFormat::FontLetterSpacingType));
|
||||
QVERIFY(properties.contains(QTextFormat::FontStretch));
|
||||
QVERIFY(properties.contains(QTextFormat::FontFamilies));
|
||||
QVERIFY(!properties.contains(QTextFormat::OldFontLetterSpacingType));
|
||||
QVERIFY(!properties.contains(QTextFormat::OldFontStretch));
|
||||
QVERIFY(!properties.contains(QTextFormat::FontFamily));
|
||||
}
|
||||
|
||||
QByteArray memory;
|
||||
@ -728,8 +731,10 @@ void tst_QTextFormat::dataStreamCompatibility()
|
||||
QMap<int, QVariant> properties = other.properties();
|
||||
QVERIFY(properties.contains(QTextFormat::FontLetterSpacingType));
|
||||
QVERIFY(properties.contains(QTextFormat::FontStretch));
|
||||
QVERIFY(properties.contains(QTextFormat::FontFamilies));
|
||||
QVERIFY(!properties.contains(QTextFormat::OldFontLetterSpacingType));
|
||||
QVERIFY(!properties.contains(QTextFormat::OldFontStretch));
|
||||
QVERIFY(!properties.contains(QTextFormat::FontFamily));
|
||||
}
|
||||
}
|
||||
|
||||
@ -746,8 +751,10 @@ void tst_QTextFormat::dataStreamCompatibility()
|
||||
stream >> properties;
|
||||
QVERIFY(properties.contains(QTextFormat::FontLetterSpacingType));
|
||||
QVERIFY(properties.contains(QTextFormat::FontStretch));
|
||||
QVERIFY(properties.contains(QTextFormat::FontFamilies));
|
||||
QVERIFY(!properties.contains(QTextFormat::OldFontLetterSpacingType));
|
||||
QVERIFY(!properties.contains(QTextFormat::OldFontStretch));
|
||||
QVERIFY(!properties.contains(QTextFormat::FontFamily));
|
||||
}
|
||||
}
|
||||
|
||||
@ -777,8 +784,10 @@ void tst_QTextFormat::dataStreamCompatibility()
|
||||
QMap<int, QVariant> properties = other.properties();
|
||||
QVERIFY(properties.contains(QTextFormat::FontLetterSpacingType));
|
||||
QVERIFY(properties.contains(QTextFormat::FontStretch));
|
||||
QVERIFY(properties.contains(QTextFormat::FontFamilies));
|
||||
QVERIFY(!properties.contains(QTextFormat::OldFontLetterSpacingType));
|
||||
QVERIFY(!properties.contains(QTextFormat::OldFontStretch));
|
||||
QVERIFY(!properties.contains(QTextFormat::FontFamily));
|
||||
}
|
||||
}
|
||||
|
||||
@ -797,8 +806,10 @@ void tst_QTextFormat::dataStreamCompatibility()
|
||||
stream >> properties;
|
||||
QVERIFY(!properties.contains(QTextFormat::FontLetterSpacingType));
|
||||
QVERIFY(!properties.contains(QTextFormat::FontStretch));
|
||||
QVERIFY(!properties.contains(QTextFormat::FontFamilies));
|
||||
QVERIFY(properties.contains(QTextFormat::OldFontLetterSpacingType));
|
||||
QVERIFY(properties.contains(QTextFormat::OldFontStretch));
|
||||
QVERIFY(properties.contains(QTextFormat::FontFamily));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -142,7 +142,7 @@ static void doShapingTests()
|
||||
if (e->fontEngine(e->layoutData->items[0])->type() == QFontEngine::Box)
|
||||
QSKIP("OpenType support missing for script");
|
||||
|
||||
QCOMPARE(e->fontEngine(e->layoutData->items[0])->fontDef.family, font.family());
|
||||
QCOMPARE(e->fontEngine(e->layoutData->items[0])->fontDef.families.first(), font.family());
|
||||
|
||||
ushort nglyphs = glyphs.size();
|
||||
if (!glyphs.isEmpty()) {
|
||||
@ -1098,7 +1098,7 @@ void tst_QTextScriptEngine::controlInSyllable_qtbug14204()
|
||||
QFontEngine *fe = e->fontEngine(e->layoutData->items[0]);
|
||||
if (fe->type() == QFontEngine::Box)
|
||||
QSKIP("OpenType support missing for script");
|
||||
QCOMPARE(fe->fontDef.family, font.family());
|
||||
QCOMPARE(fe->fontDef.families.first(), font.family());
|
||||
|
||||
e->shape(0);
|
||||
QCOMPARE(e->layoutData->items[0].num_glyphs, ushort(3));
|
||||
@ -1156,7 +1156,7 @@ void tst_QTextScriptEngine::combiningMarks_qtbug15675()
|
||||
QFontEngine *fe = e->fontEngine(e->layoutData->items[0]);
|
||||
if (fe->type() == QFontEngine::Box)
|
||||
QSKIP("OpenType support missing for script");
|
||||
QCOMPARE(fe->fontDef.family, font.family());
|
||||
QCOMPARE(fe->fontDef.families.first(), font.family());
|
||||
|
||||
e->shape(0);
|
||||
const int diff = e->layoutData->items[0].num_glyphs - string.size();
|
||||
@ -1197,7 +1197,7 @@ void tst_QTextScriptEngine::thaiIsolatedSaraAm()
|
||||
QFontEngine *fe = e->fontEngine(e->layoutData->items[0]);
|
||||
if (fe->type() == QFontEngine::Box)
|
||||
QSKIP("OpenType support missing for script");
|
||||
QCOMPARE(fe->fontDef.family, font.family());
|
||||
QCOMPARE(fe->fontDef.families.first(), font.family());
|
||||
|
||||
e->shape(0);
|
||||
QVERIFY(e->layoutData->items[0].num_glyphs > 0);
|
||||
|
@ -91,7 +91,7 @@ void tst_QFontComboBox::currentFont_data()
|
||||
// Normalize the names
|
||||
QFont defaultFont;
|
||||
QFontInfo fi(defaultFont);
|
||||
defaultFont = QFont(fi.family()); // make sure we have a real font name and not something like 'Sans Serif'.
|
||||
defaultFont = QFont(QStringList{fi.family()}); // make sure we have a real font name and not something like 'Sans Serif'.
|
||||
if (!QFontDatabase::isPrivateFamily(defaultFont.family()))
|
||||
QTest::newRow("default") << defaultFont;
|
||||
defaultFont.setPointSize(defaultFont.pointSize() + 10);
|
||||
@ -99,8 +99,8 @@ void tst_QFontComboBox::currentFont_data()
|
||||
QTest::newRow("default2") << defaultFont;
|
||||
QStringList list = QFontDatabase::families();
|
||||
for (int i = 0; i < list.count(); ++i) {
|
||||
QFont f = QFont(QFontInfo(QFont(list.at(i))).family());
|
||||
if (!QFontDatabase::isPrivateFamily(f.family()))
|
||||
QFont f = QFont(QStringList{QFontInfo(QFont(list.at(i))).family()});
|
||||
if (!QFontDatabase::isPrivateFamily(f.families().first()))
|
||||
QTest::newRow(qPrintable(list.at(i))) << f;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user