aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/items/context2d
diff options
context:
space:
mode:
authorJonas Karlsson <jonas.karlsson@qt.io>2020-08-06 16:57:50 +0200
committerJonas Karlsson <jonas.karlsson@qt.io>2020-08-28 18:33:08 +0200
commitde0c76db907ffd34b10eeda4a2d1d52c107ef4bd (patch)
treec49a4a6045971f31c36adbf69b886025ccabd2ee /src/quick/items/context2d
parentf1cc8f684cf7a72c70dfe4d9c1ca0a03ad0030a9 (diff)
Use OpenType font weights
Task-number: QTBUG-42248 Change-Id: Ib26d4945307b630b054e270b3213e1c9ad0d5357 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
Diffstat (limited to 'src/quick/items/context2d')
-rw-r--r--src/quick/items/context2d/qquickcontext2d.cpp20
1 files changed, 8 insertions, 12 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 &current
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