diff options
Diffstat (limited to 'src/gui/text/qfont.cpp')
-rw-r--r-- | src/gui/text/qfont.cpp | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/src/gui/text/qfont.cpp b/src/gui/text/qfont.cpp index 316e92123e..3c6c9d3f66 100644 --- a/src/gui/text/qfont.cpp +++ b/src/gui/text/qfont.cpp @@ -31,6 +31,8 @@ #include <QtCore/QMutexLocker> #include <QtCore/QMutex> +#include <array> + // #define QFONTCACHE_DEBUG #ifdef QFONTCACHE_DEBUG # define FC_DEBUG qDebug @@ -140,7 +142,7 @@ Q_GUI_EXPORT int qt_defaultDpi() /* Helper function to convert between legacy Qt and OpenType font weights. */ static int convertWeights(int weight, bool inverted) { - static const QVarLengthArray<QPair<int, int>, 9> legacyToOpenTypeMap = { + static constexpr std::array<int, 2> legacyToOpenTypeMap[] = { { 0, QFont::Thin }, { 12, QFont::ExtraLight }, { 25, QFont::Light }, { 50, QFont::Normal }, { 57, QFont::Medium }, { 63, QFont::DemiBold }, { 75, QFont::Bold }, { 81, QFont::ExtraBold }, { 87, QFont::Black }, @@ -151,8 +153,8 @@ static int convertWeights(int weight, bool inverted) // Go through and find the closest mapped value for (auto mapping : legacyToOpenTypeMap) { - const int weightOld = inverted ? mapping.second : mapping.first; - const int weightNew = inverted ? mapping.first : mapping.second; + const int weightOld = mapping[ inverted]; + const int weightNew = mapping[!inverted]; const int dist = qAbs(weightOld - weight); if (dist < closestDist) { result = weightNew; @@ -179,7 +181,7 @@ static QStringList splitIntoFamilies(const QString &family) auto str = list.at(i).trimmed(); if ((str.startsWith(u'"') && str.endsWith(u'"')) || (str.startsWith(u'\'') && str.endsWith(u'\''))) { - str = str.mid(1, str.length() - 2); + str = str.mid(1, str.size() - 2); } familyList << str.toString(); } @@ -1011,7 +1013,8 @@ qreal QFont::pointSizeF() const } /*! - Sets the font size to \a pixelSize pixels. + Sets the font size to \a pixelSize pixels, with a maxiumum size + of an unsigned 16-bit integer. Using this function makes the font device dependent. Use setPointSize() or setPointSizeF() to set the size of the font @@ -2125,7 +2128,7 @@ bool QFont::fromString(const QString &descrip) { const auto sr = QStringView(descrip).trimmed(); const auto l = sr.split(u','); - const int count = l.count(); + const int count = l.size(); if (!count || (count > 2 && count < 9) || count == 9 || count > 17 || l.first().isEmpty()) { qWarning("QFont::fromString: Invalid description '%s'", |