summaryrefslogtreecommitdiffstats
path: root/src/gui
diff options
context:
space:
mode:
authorAndy Shaw <andy.shaw@qt.io>2020-10-19 11:39:24 +0200
committerAndy Shaw <andy.shaw@qt.io>2020-11-20 14:30:22 +0100
commitd8602ce58b6ef268be84b9aa0166b0c3fa6a96e8 (patch)
tree3665176e38aac64015213085f3d0e867ec11e612 /src/gui
parent13c460d0ff1a4eecfb7b1bc43a863783ed59a2bd (diff)
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>
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/painting/qpainter.cpp2
-rw-r--r--src/gui/text/coretext/qfontengine_coretext.mm2
-rw-r--r--src/gui/text/freetype/qfontengine_ft.cpp6
-rw-r--r--src/gui/text/qcssparser.cpp1
-rw-r--r--src/gui/text/qfont.cpp156
-rw-r--r--src/gui/text/qfont.h1
-rw-r--r--src/gui/text/qfont_p.h4
-rw-r--r--src/gui/text/qfontdatabase.cpp48
-rw-r--r--src/gui/text/qfontengine.cpp21
-rw-r--r--src/gui/text/qfontsubset.cpp2
-rw-r--r--src/gui/text/qrawfont.cpp2
-rw-r--r--src/gui/text/qtextdocument.cpp6
-rw-r--r--src/gui/text/qtextformat.cpp15
-rw-r--r--src/gui/text/qtextformat.h12
-rw-r--r--src/gui/text/qtexthtmlparser.cpp5
-rw-r--r--src/gui/text/qtextmarkdownimporter.cpp10
-rw-r--r--src/gui/text/unix/qfontconfigdatabase.cpp2
-rw-r--r--src/gui/text/windows/qwindowsdirectwritefontdatabase.cpp4
-rw-r--r--src/gui/text/windows/qwindowsfontdatabase.cpp30
-rw-r--r--src/gui/text/windows/qwindowsfontdatabase_ft.cpp4
-rw-r--r--src/gui/text/windows/qwindowsfontdatabasebase.cpp4
-rw-r--r--src/gui/text/windows/qwindowsfontengine.cpp8
22 files changed, 184 insertions, 161 deletions
diff --git a/src/gui/painting/qpainter.cpp b/src/gui/painting/qpainter.cpp
index 6bc440b5b3..853de39e73 100644
--- a/src/gui/painting/qpainter.cpp
+++ b/src/gui/painting/qpainter.cpp
@@ -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) {
diff --git a/src/gui/text/coretext/qfontengine_coretext.mm b/src/gui/text/coretext/qfontengine_coretext.mm
index d066d6f5a1..0070e18ade 100644
--- a/src/gui/text/coretext/qfontengine_coretext.mm
+++ b/src/gui/text/coretext/qfontengine_coretext.mm
@@ -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;
diff --git a/src/gui/text/freetype/qfontengine_ft.cpp b/src/gui/text/freetype/qfontengine_ft.cpp
index 42cf147901..9644149754 100644
--- a/src/gui/text/freetype/qfontengine_ft.cpp
+++ b/src/gui/text/freetype/qfontengine_ft.cpp
@@ -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();
diff --git a/src/gui/text/qcssparser.cpp b/src/gui/text/qcssparser.cpp
index 9670568792..05a5ec4420 100644
--- a/src/gui/text/qcssparser.cpp
+++ b/src/gui/text/qcssparser.cpp
@@ -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;
}
diff --git a/src/gui/text/qfont.cpp b/src/gui/text/qfont.cpp
index 53344418a0..0e680a3c6d 100644
--- a/src/gui/text/qfont.cpp
+++ b/src/gui/text/qfont.cpp
@@ -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";
diff --git a/src/gui/text/qfont.h b/src/gui/text/qfont.h
index 97b62b385e..f9af52f537 100644
--- a/src/gui/text/qfont.h
+++ b/src/gui/text/qfont.h
@@ -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
diff --git a/src/gui/text/qfont_p.h b/src/gui/text/qfont_p.h
index abf6d000e7..f285111c4a 100644
--- a/src/gui/text/qfont_p.h
+++ b/src/gui/text/qfont_p.h
@@ -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);
diff --git a/src/gui/text/qfontdatabase.cpp b/src/gui/text/qfontdatabase.cpp
index 13cde04ff4..69c4b8c92f 100644
--- a/src/gui/text/qfontdatabase.cpp
+++ b/src/gui/text/qfontdatabase.cpp
@@ -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;
diff --git a/src/gui/text/qfontengine.cpp b/src/gui/text/qfontengine.cpp
index 470a04638e..d526dcc7ac 100644
--- a/src/gui/text/qfontengine.cpp
+++ b/src/gui/text/qfontengine.cpp
@@ -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
diff --git a/src/gui/text/qfontsubset.cpp b/src/gui/text/qfontsubset.cpp
index f0b64e114b..0c60bf7b70 100644
--- a/src/gui/text/qfontsubset.cpp
+++ b/src/gui/text/qfontsubset.cpp
@@ -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);
diff --git a/src/gui/text/qrawfont.cpp b/src/gui/text/qrawfont.cpp
index 33c0825c6a..918cec6fa2 100644
--- a/src/gui/text/qrawfont.cpp
+++ b/src/gui/text/qrawfont.cpp
@@ -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();
}
/*!
diff --git a/src/gui/text/qtextdocument.cpp b/src/gui/text/qtextdocument.cpp
index c9a8153314..0fae775bae 100644
--- a/src/gui/text/qtextdocument.cpp
+++ b/src/gui/text/qtextdocument.cpp
@@ -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();
}
/*!
diff --git a/src/gui/text/qtextformat.cpp b/src/gui/text/qtextformat.cpp
index e113fad8fa..1da04b871a 100644
--- a/src/gui/text/qtextformat.cpp
+++ b/src/gui/text/qtextformat.cpp
@@ -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)
diff --git a/src/gui/text/qtextformat.h b/src/gui/text/qtextformat.h
index 87de1e7fbd..9cdd34be2c 100644
--- a/src/gui/text/qtextformat.h
+++ b/src/gui/text/qtextformat.h
@@ -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)); }
diff --git a/src/gui/text/qtexthtmlparser.cpp b/src/gui/text/qtexthtmlparser.cpp
index 996980b764..ed1c6d97f6 100644
--- a/src/gui/text/qtexthtmlparser.cpp
+++ b/src/gui/text/qtexthtmlparser.cpp
@@ -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;
diff --git a/src/gui/text/qtextmarkdownimporter.cpp b/src/gui/text/qtextmarkdownimporter.cpp
index 77ca588f00..1e18f31c30 100644
--- a/src/gui/text/qtextmarkdownimporter.cpp
+++ b/src/gui/text/qtextmarkdownimporter.cpp
@@ -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
diff --git a/src/gui/text/unix/qfontconfigdatabase.cpp b/src/gui/text/unix/qfontconfigdatabase.cpp
index a8e28618f4..dff11eb172 100644
--- a/src/gui/text/unix/qfontconfigdatabase.cpp
+++ b/src/gui/text/unix/qfontconfigdatabase.cpp
@@ -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);
diff --git a/src/gui/text/windows/qwindowsdirectwritefontdatabase.cpp b/src/gui/text/windows/qwindowsdirectwritefontdatabase.cpp
index c0d9e820c6..7a4ce0930a 100644
--- a/src/gui/text/windows/qwindowsdirectwritefontdatabase.cpp
+++ b/src/gui/text/windows/qwindowsdirectwritefontdatabase.cpp
@@ -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))) {
diff --git a/src/gui/text/windows/qwindowsfontdatabase.cpp b/src/gui/text/windows/qwindowsfontdatabase.cpp
index 79ea08f9b6..381bcea0b3 100644
--- a/src/gui/text/windows/qwindowsfontdatabase.cpp
+++ b/src/gui/text/windows/qwindowsfontdatabase.cpp
@@ -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);
diff --git a/src/gui/text/windows/qwindowsfontdatabase_ft.cpp b/src/gui/text/windows/qwindowsfontdatabase_ft.cpp
index d047532c3c..e2c8d3455d 100644
--- a/src/gui/text/windows/qwindowsfontdatabase_ft.cpp
+++ b/src/gui/text/windows/qwindowsfontdatabase_ft.cpp
@@ -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;
}
diff --git a/src/gui/text/windows/qwindowsfontdatabasebase.cpp b/src/gui/text/windows/qwindowsfontdatabasebase.cpp
index b84fe20c93..279f696bbd 100644
--- a/src/gui/text/windows/qwindowsfontdatabasebase.cpp
+++ b/src/gui/text/windows/qwindowsfontdatabasebase.cpp
@@ -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();
diff --git a/src/gui/text/windows/qwindowsfontengine.cpp b/src/gui/text/windows/qwindowsfontengine.cpp
index a8dba8b1f2..3335fcdc99 100644
--- a/src/gui/text/windows/qwindowsfontengine.cpp
+++ b/src/gui/text/windows/qwindowsfontengine.cpp
@@ -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;