summaryrefslogtreecommitdiffstats
path: root/src/gui/text/qfont.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/text/qfont.cpp')
-rw-r--r--src/gui/text/qfont.cpp64
1 files changed, 53 insertions, 11 deletions
diff --git a/src/gui/text/qfont.cpp b/src/gui/text/qfont.cpp
index 2bea0e9a07..9f16af0222 100644
--- a/src/gui/text/qfont.cpp
+++ b/src/gui/text/qfont.cpp
@@ -116,19 +116,36 @@ bool QFontDef::exactMatch(const QFontDef &other) const
if (stretch != 0 && other.stretch != 0 && stretch != other.stretch)
return false;
- if (families.size() != other.families.size())
+ // 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 < families.size(); ++i) {
- QFontDatabase::parseFontName(families.at(i), this_foundry, this_family);
- QFontDatabase::parseFontName(other.families.at(i), other_foundry, other_family);
+ for (int i = 0; i < origFamilies.size(); ++i) {
+ QFontDatabase::parseFontName(origFamilies.at(i), this_foundry, this_family);
+ QFontDatabase::parseFontName(otherFamilies.at(i), other_foundry, other_family);
if (this_family != other_family || this_foundry != other_foundry)
return false;
}
- QFontDatabase::parseFontName(family, this_foundry, this_family);
- QFontDatabase::parseFontName(other.family, other_foundry, other_family);
+ // Check family only if families is not set
+ if (origFamilies.size() == 0) {
+ QFontDatabase::parseFontName(family, this_foundry, this_family);
+ QFontDatabase::parseFontName(other.family, other_foundry, other_family);
+ }
return (styleHint == other.styleHint
&& styleStrategy == other.styleStrategy
@@ -203,8 +220,10 @@ QFontPrivate::~QFontPrivate()
if (engineData && !engineData->ref.deref())
delete engineData;
engineData = nullptr;
- if (scFont && scFont != this)
- scFont->ref.deref();
+ if (scFont && scFont != this) {
+ if (!scFont->ref.deref())
+ delete scFont;
+ }
scFont = nullptr;
}
@@ -613,8 +632,10 @@ void QFont::detach()
if (d->engineData && !d->engineData->ref.deref())
delete d->engineData;
d->engineData = nullptr;
- if (d->scFont && d->scFont != d.data())
- d->scFont->ref.deref();
+ if (d->scFont && d->scFont != d.data()) {
+ if (!d->scFont->ref.deref())
+ delete d->scFont;
+ }
d->scFont = nullptr;
return;
}
@@ -2063,7 +2084,26 @@ QString QFont::key() const
/*!
Returns a description of the font. The description is a
comma-separated list of the attributes, perfectly suited for use
- in QSettings.
+ in QSettings, and consists of the following:
+
+ \list
+ \li Font family
+ \li Point size
+ \li Pixel size
+ \li Style hint
+ \li Font weight
+ \li Font style
+ \li Underline
+ \li Strike out
+ \li Fixed pitch
+ \li Always \e{0}
+ \li Capitalization
+ \li Letter spacing
+ \li Word spacing
+ \li Stretch
+ \li Style strategy
+ \li Font style (omitted when unavailable)
+ \endlist
\sa fromString()
*/
@@ -3280,3 +3320,5 @@ QDebug operator<<(QDebug stream, const QFont &font)
#endif
QT_END_NAMESPACE
+
+#include "moc_qfont.cpp"