diff options
author | Jonas Karlsson <[email protected]> | 2020-08-06 16:57:50 +0200 |
---|---|---|
committer | Jonas Karlsson <[email protected]> | 2020-08-28 18:33:08 +0200 |
commit | de0c76db907ffd34b10eeda4a2d1d52c107ef4bd (patch) | |
tree | c49a4a6045971f31c36adbf69b886025ccabd2ee /src | |
parent | f1cc8f684cf7a72c70dfe4d9c1ca0a03ad0030a9 (diff) |
Use OpenType font weights
Task-number: QTBUG-42248
Change-Id: Ib26d4945307b630b054e270b3213e1c9ad0d5357
Reviewed-by: Eskil Abrahamsen Blomfeldt <[email protected]>
Diffstat (limited to 'src')
-rw-r--r-- | src/quick/items/context2d/qquickcontext2d.cpp | 20 | ||||
-rw-r--r-- | src/quick/items/qquicktext.cpp | 2 | ||||
-rw-r--r-- | src/quick/items/qquicktextedit.cpp | 2 | ||||
-rw-r--r-- | src/quick/items/qquicktextinput.cpp | 2 | ||||
-rw-r--r-- | src/quick/util/qquickfontloader.cpp | 2 | ||||
-rw-r--r-- | src/quick/util/qquickglobal.cpp | 2 | ||||
-rw-r--r-- | src/quick/util/qquickvaluetypes.cpp | 2 |
7 files changed, 14 insertions, 18 deletions
diff --git a/src/quick/items/context2d/qquickcontext2d.cpp b/src/quick/items/context2d/qquickcontext2d.cpp index 5a7af4835e..bae9906059 100644 --- a/src/quick/items/context2d/qquickcontext2d.cpp +++ b/src/quick/items/context2d/qquickcontext2d.cpp @@ -452,18 +452,14 @@ static QFont qt_font_from_string(const QString& fontString, const QFont ¤t bool conversionOk = false; int weight = token.toInt(&conversionOk); if (conversionOk) { - if (weight >= 0 && weight <= 99) { - Q_TRY_SET_TOKEN(FontWeight, "<font-weight>", newFont.setWeight(weight)) - continue; - } else { - qWarning().nospace() << "Context2D: Invalid font weight " << weight << " found in font string; " - << "must be between 0 and 99, inclusive."; - return currentFont; - } + Q_TRY_SET_TOKEN(FontWeight, "<font-weight>", + newFont.setWeight(QFont::Weight(weight))) + } else { + // The token is invalid or in the wrong place/order in the font string. + qWarning().nospace() << "Context2D: Invalid or misplaced token " << token + << " found in font string."; + return currentFont; } - // The token is invalid or in the wrong place/order in the font string. - qWarning().nospace() << "Context2D: Invalid or misplaced token " << token << " found in font string."; - return currentFont; } } return newFont; @@ -2793,7 +2789,7 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_caretBlinkRate(const QV4:: \li font-style (optional): normal | italic | oblique \li font-variant (optional): normal | small-caps - \li font-weight (optional): normal | bold | 0 ... 99 + \li font-weight (optional): normal | bold | 1 ... 1000 \li font-size: Npx | Npt (where N is a positive number) \li font-family: See \l {http://www.w3.org/TR/CSS2/fonts.html#propdef-font-family} \endlist diff --git a/src/quick/items/qquicktext.cpp b/src/quick/items/qquicktext.cpp index b198c5f114..e89bb49e83 100644 --- a/src/quick/items/qquicktext.cpp +++ b/src/quick/items/qquicktext.cpp @@ -1474,7 +1474,7 @@ QQuickText::~QQuickText() \qmlproperty int QtQuick::Text::font.weight The requested weight of the font. The weight requested must be an integer - between 0 and 99, or one of the predefined values: + between 1 and 1000, or one of the predefined values: \list \li Font.Thin \li Font.Light diff --git a/src/quick/items/qquicktextedit.cpp b/src/quick/items/qquicktextedit.cpp index f5a32b8d88..aa07758a5d 100644 --- a/src/quick/items/qquicktextedit.cpp +++ b/src/quick/items/qquicktextedit.cpp @@ -234,7 +234,7 @@ QString QQuickTextEdit::text() const \qmlproperty int QtQuick::TextEdit::font.weight The requested weight of the font. The weight requested must be an integer - between 0 and 99, or one of the predefined values: + between 1 and 1000, or one of the predefined values: \list \li Font.Thin \li Font.Light diff --git a/src/quick/items/qquicktextinput.cpp b/src/quick/items/qquicktextinput.cpp index db2db9a9d7..64faf4ac33 100644 --- a/src/quick/items/qquicktextinput.cpp +++ b/src/quick/items/qquicktextinput.cpp @@ -258,7 +258,7 @@ QString QQuickTextInputPrivate::realText() const \qmlproperty int QtQuick::TextInput::font.weight The requested weight of the font. The weight requested must be an integer - between 0 and 99, or one of the predefined values: + between 1 and 1000, or one of the predefined values: \list \li Font.Thin \li Font.Light diff --git a/src/quick/util/qquickfontloader.cpp b/src/quick/util/qquickfontloader.cpp index d6858b486c..2ae5d00739 100644 --- a/src/quick/util/qquickfontloader.cpp +++ b/src/quick/util/qquickfontloader.cpp @@ -309,7 +309,7 @@ void QQuickFontLoader::updateFontInfo(int id) const QFontDatabasePrivate::ApplicationFont::Properties &properties = applicationFont.properties.at(0); font.setFamily(properties.familyName); font.setStyleName(properties.styleName); - font.setWeight(properties.weight); + font.setWeight(QFont::Weight(properties.weight)); font.setStyle(properties.style); font.setStretch(properties.stretch); } diff --git a/src/quick/util/qquickglobal.cpp b/src/quick/util/qquickglobal.cpp index 817977eb3b..fb1645803f 100644 --- a/src/quick/util/qquickglobal.cpp +++ b/src/quick/util/qquickglobal.cpp @@ -528,7 +528,7 @@ public: if (ok) *ok = true; } if (vweight->isInt32()) { - retn.setWeight(vweight->integerValue()); + retn.setWeight(QFont::Weight(vweight->integerValue())); if (ok) *ok = true; } if (vwspac->isNumber()) { diff --git a/src/quick/util/qquickvaluetypes.cpp b/src/quick/util/qquickvaluetypes.cpp index 666156d1cd..b2131b53b7 100644 --- a/src/quick/util/qquickvaluetypes.cpp +++ b/src/quick/util/qquickvaluetypes.cpp @@ -654,7 +654,7 @@ int QQuickFontValueType::weight() const void QQuickFontValueType::setWeight(int w) { - v.setWeight(qBound(0, w, 99)); + v.setWeight(QFont::Weight(w)); } bool QQuickFontValueType::italic() const |