From 46e8ac03083f1180ee1b8468e3285da8a26598de Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Wed, 13 May 2015 11:24:07 +0200 Subject: Extend generated style strings to include new font weights MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Reviewed-by: René J.V. Bertin Reviewed-by: Pierre Rossi --- src/gui/text/qfontdatabase.cpp | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) (limited to 'src/gui/text') 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(); } -- cgit v1.2.3