diff options
author | Allan Sandfeld Jensen <allan.jensen@theqtcompany.com> | 2015-05-13 11:24:07 +0200 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@theqtcompany.com> | 2015-06-15 23:16:07 +0000 |
commit | 46e8ac03083f1180ee1b8468e3285da8a26598de (patch) | |
tree | 21ec27ad4c5ee1b1e4e3244cd268a2599fafe29b | |
parent | 7c8b3699bfc42c0d54b7dd0855cd244f2cff388b (diff) | |
download | qtbase-46e8ac03083f1180ee1b8468e3285da8a26598de.tar.gz |
Extend generated style strings to include new font weights
When a font style-name is not directly available from the font we
need to generate it with the data we have, so we should include all
the new supported weights.
Change-Id: I45cc0114f8c76f45bc7a639f9d0d8096a064bc51
Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
Reviewed-by: René J.V. Bertin <rjvbertin@gmail.com>
Reviewed-by: Pierre Rossi <pierre.rossi@theqtcompany.com>
-rw-r--r-- | src/gui/text/qfontdatabase.cpp | 29 |
1 files changed, 20 insertions, 9 deletions
diff --git a/src/gui/text/qfontdatabase.cpp b/src/gui/text/qfontdatabase.cpp index dae4d560a8..6b7a9837cb 100644 --- a/src/gui/text/qfontdatabase.cpp +++ b/src/gui/text/qfontdatabase.cpp @@ -1184,14 +1184,25 @@ static int match(int script, const QFontDef &request, static QString styleStringHelper(int weight, QFont::Style style) { QString result; - if (weight >= QFont::Black) - result = QCoreApplication::translate("QFontDatabase", "Black"); - else if (weight >= QFont::Bold) - result = QCoreApplication::translate("QFontDatabase", "Bold"); - else if (weight >= QFont::DemiBold) - result = QCoreApplication::translate("QFontDatabase", "Demi Bold"); - else if (weight < QFont::Normal) - result = QCoreApplication::translate("QFontDatabase", "Light"); + if (weight > QFont::Normal) { + if (weight >= QFont::Black) + result = QCoreApplication::translate("QFontDatabase", "Black"); + else if (weight >= QFont::ExtraBold) + result = QCoreApplication::translate("QFontDatabase", "Extra Bold"); + else if (weight >= QFont::Bold) + result = QCoreApplication::translate("QFontDatabase", "Bold"); + else if (weight >= QFont::DemiBold) + result = QCoreApplication::translate("QFontDatabase", "Demi Bold"); + else if (weight >= QFont::Medium) + result = QCoreApplication::translate("QFontDatabase", "Medium", "The Medium font weight"); + } else { + if (weight <= QFont::Thin) + result = QCoreApplication::translate("QFontDatabase", "Thin"); + else if (weight <= QFont::ExtraLight) + result = QCoreApplication::translate("QFontDatabase", "Extra Light"); + else if (weight <= QFont::Light) + result = QCoreApplication::translate("QFontDatabase", "Light"); + } if (style == QFont::StyleItalic) result += QLatin1Char(' ') + QCoreApplication::translate("QFontDatabase", "Italic"); @@ -1199,7 +1210,7 @@ static QString styleStringHelper(int weight, QFont::Style style) result += QLatin1Char(' ') + QCoreApplication::translate("QFontDatabase", "Oblique"); if (result.isEmpty()) - result = QCoreApplication::translate("QFontDatabase", "Normal"); + result = QCoreApplication::translate("QFontDatabase", "Normal", "The Normal or Regular font weight"); return result.simplified(); } |