diff options
Diffstat (limited to 'src/gui/text/qfont.cpp')
| -rw-r--r-- | src/gui/text/qfont.cpp | 48 |
1 files changed, 9 insertions, 39 deletions
diff --git a/src/gui/text/qfont.cpp b/src/gui/text/qfont.cpp index 17ed5fb7ed4..ba49d538c2c 100644 --- a/src/gui/text/qfont.cpp +++ b/src/gui/text/qfont.cpp @@ -31,6 +31,7 @@ #include <QtCore/QMutexLocker> #include <QtCore/QMutex> +#include <algorithm> #include <array> // #define QFONTCACHE_DEBUG @@ -1853,35 +1854,13 @@ bool QFont::operator<(const QFont &f) const int f2attrs = (d->underline << 3) + (d->overline << 2) + (d->strikeOut<<1) + d->kerning; if (f1attrs != f2attrs) return f1attrs < f2attrs; - if (d->features.size() != f.d->features.size()) - return f.d->features.size() < d->features.size(); - - { - auto it = d->features.constBegin(); - auto jt = f.d->features.constBegin(); - for (; it != d->features.constEnd(); ++it, ++jt) { - if (it.key() != jt.key()) - return jt.key() < it.key(); - if (it.value() != jt.value()) - return jt.value() < it.value(); - } + if (d->features != f.d->features) { + return std::lexicographical_compare(f.d->features.keyValueBegin(), f.d->features.keyValueEnd(), + d->features.keyValueBegin(), d->features.keyValueEnd()); } - if (r1.variableAxisValues.size() != r2.variableAxisValues.size()) - return r1.variableAxisValues.size() < r2.variableAxisValues.size(); - - { - auto it = r1.variableAxisValues.constBegin(); - auto jt = r2.variableAxisValues.constBegin(); - for (; it != r1.variableAxisValues.constEnd(); ++it, ++jt) { - if (it.key() != jt.key()) - return jt.key() < it.key(); - if (it.value() != jt.value()) - return jt.value() < it.value(); - } - } - - return false; + return std::lexicographical_compare(r1.variableAxisValues.keyValueBegin(), r1.variableAxisValues.keyValueEnd(), + r2.variableAxisValues.keyValueBegin(), r2.variableAxisValues.keyValueEnd()); } @@ -2265,8 +2244,7 @@ bool QFont::fromString(const QString &descrip) const auto sr = QStringView(descrip).trimmed(); const auto l = sr.split(u','); const int count = l.size(); - if (!count || (count > 2 && count < 9) || count == 9 || - l.first().isEmpty()) { + if (!count || (count > 2 && count < 10) || l.first().isEmpty()) { qWarning("QFont::fromString: Invalid description '%s'", descrip.isEmpty() ? "(empty)" : descrip.toLatin1().data()); return false; @@ -2275,16 +2253,8 @@ bool QFont::fromString(const QString &descrip) setFamily(l[0].toString()); if (count > 1 && l[1].toDouble() > 0.0) setPointSizeF(l[1].toDouble()); - if (count == 9) { - setStyleHint((StyleHint) l[2].toInt()); - setWeight(QFont::Weight(l[3].toInt())); - setItalic(l[4].toInt()); - setUnderline(l[5].toInt()); - setStrikeOut(l[6].toInt()); - setFixedPitch(l[7].toInt()); - if (!d->request.fixedPitch) // assume 'false' fixedPitch equals default - d->request.ignorePitch = true; - } else if (count >= 10) { + + if (count >= 10) { if (l[2].toInt() > 0) setPixelSize(l[2].toInt()); setStyleHint((StyleHint) l[3].toInt()); |
