diff --git a/src/gui/text/qfont.cpp b/src/gui/text/qfont.cpp index 2b649a7dd8..0db9bbac3f 100644 --- a/src/gui/text/qfont.cpp +++ b/src/gui/text/qfont.cpp @@ -31,6 +31,8 @@ #include #include +#include + // #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, 9> legacyToOpenTypeMap = { + static constexpr std::array 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;