summaryrefslogtreecommitdiffstats
path: root/src/plugins/platformthemes/gtk2
diff options
context:
space:
mode:
authorPierre Rossi <pierre.rossi@digia.com>2014-10-22 17:14:29 +0200
committerKonstantin Ritt <ritt.ks@gmail.com>2014-12-12 06:59:46 +0100
commit517da68893be9e6d97c7993922c573de9560604d (patch)
tree9da6027604c97023fd6cacc3114c2f2fd43dd26f /src/plugins/platformthemes/gtk2
parent0478bc15bd3b4c616b4860e460600ba8877ee216 (diff)
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 <ritt.ks@gmail.com> Reviewed-by: Gabriel de Dietrich <gabriel.dedietrich@theqtcompany.com>
Diffstat (limited to 'src/plugins/platformthemes/gtk2')
-rw-r--r--src/plugins/platformthemes/gtk2/qgtk2dialoghelpers.cpp24
1 files changed, 12 insertions, 12 deletions
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 <qfont.h>
#include <private/qguiapplication_p.h>
+#include <qpa/qplatformfontdatabase.h>
#undef signals
#include <gtk/gtk.h>
@@ -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)