From 517da68893be9e6d97c7993922c573de9560604d Mon Sep 17 00:00:00 2001 From: Pierre Rossi Date: Wed, 22 Oct 2014 17:14:29 +0200 Subject: Add QFont::Weight enum values And try to make good use of them in order to match the QFont request more closely. Task-number: QTBUG-38482 Change-Id: I768dfa8828e370d77a1c17ecf4796d750b3edd9b Reviewed-by: Konstantin Ritt Reviewed-by: Gabriel de Dietrich --- .../platformthemes/gtk2/qgtk2dialoghelpers.cpp | 24 +++++++++++----------- 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'src/plugins/platformthemes') diff --git a/src/plugins/platformthemes/gtk2/qgtk2dialoghelpers.cpp b/src/plugins/platformthemes/gtk2/qgtk2dialoghelpers.cpp index d7e73c873d..0c7ff1a717 100644 --- a/src/plugins/platformthemes/gtk2/qgtk2dialoghelpers.cpp +++ b/src/plugins/platformthemes/gtk2/qgtk2dialoghelpers.cpp @@ -40,6 +40,7 @@ #include #include +#include #undef signals #include @@ -511,14 +512,22 @@ static QString qt_fontToString(const QFont &font) int weight = font.weight(); if (weight >= QFont::Black) pango_font_description_set_weight(desc, PANGO_WEIGHT_HEAVY); + else if (weight >= QFont::ExtraBold) + pango_font_description_set_weight(desc, PANGO_WEIGHT_ULTRABOLD); else if (weight >= QFont::Bold) pango_font_description_set_weight(desc, PANGO_WEIGHT_BOLD); else if (weight >= QFont::DemiBold) pango_font_description_set_weight(desc, PANGO_WEIGHT_SEMIBOLD); + else if (weight >= QFont::Medium) + pango_font_description_set_weight(desc, PANGO_WEIGHT_MEDIUM); else if (weight >= QFont::Normal) pango_font_description_set_weight(desc, PANGO_WEIGHT_NORMAL); - else + else if (weight >= QFont::Light) pango_font_description_set_weight(desc, PANGO_WEIGHT_LIGHT); + else if (weight >= QFont::ExtraLight) + pango_font_description_set_weight(desc, PANGO_WEIGHT_ULTRALIGHT); + else + pango_font_description_set_weight(desc, PANGO_WEIGHT_THIN); int style = font.style(); if (style == QFont::StyleItalic) @@ -545,17 +554,8 @@ static QFont qt_fontFromString(const QString &name) if (!family.isEmpty()) font.setFamily(family); - int weight = pango_font_description_get_weight(desc); - if (weight >= PANGO_WEIGHT_HEAVY) - font.setWeight(QFont::Black); - else if (weight >= PANGO_WEIGHT_BOLD) - font.setWeight(QFont::Bold); - else if (weight >= PANGO_WEIGHT_SEMIBOLD) - font.setWeight(QFont::DemiBold); - else if (weight >= PANGO_WEIGHT_NORMAL) - font.setWeight(QFont::Normal); - else - font.setWeight(QFont::Light); + const int weight = pango_font_description_get_weight(desc); + font.setWeight(QPlatformFontDatabase::weightFromInteger(weight)); PangoStyle style = pango_font_description_get_style(desc); if (style == PANGO_STYLE_ITALIC) -- cgit v1.2.3