From d8e65d5756c937fc3d9be3e5c30b31914a437393 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Mon, 22 Feb 2016 15:07:21 +0100 Subject: Fix font dialog with missing font family and pixel sizes Two related errors: When a non-existent font was set on the font dialog, the GTK native font dialog would just pick a default one. Also, if the font size was specified with pixel size, we would request -1 as the point size from Pango. The fix for both is to resolve the font before applying it to the font dialog, and set the actually resolved family, as well as point size. Note that if the point size is explicitly set, then we pass this to the font dialog, since the one returned by QFontInfo will always be calculated based on the (rounded) pixel size, so it will usually not match the request. This fixes tst_qfontdialog::setFont(). [ChangeLog][GTK2][Dialogs] Fixed requesting a font from font dialog with a non-existent family name and/or pixel size. Task-number: QTBUG-51148 Change-Id: Id9c783407778546b0cf3f9c3ab19f124e76c878e Reviewed-by: Shawn Rutledge Reviewed-by: J-P Nurmi --- src/plugins/platformthemes/gtk2/qgtk2dialoghelpers.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/plugins/platformthemes') diff --git a/src/plugins/platformthemes/gtk2/qgtk2dialoghelpers.cpp b/src/plugins/platformthemes/gtk2/qgtk2dialoghelpers.cpp index 857f373759..f0a54ec92f 100644 --- a/src/plugins/platformthemes/gtk2/qgtk2dialoghelpers.cpp +++ b/src/plugins/platformthemes/gtk2/qgtk2dialoghelpers.cpp @@ -517,8 +517,8 @@ void QGtk2FontDialogHelper::hide() static QString qt_fontToString(const QFont &font) { PangoFontDescription *desc = pango_font_description_new(); - pango_font_description_set_size(desc, font.pointSizeF() * PANGO_SCALE); - pango_font_description_set_family(desc, font.family().toUtf8()); + pango_font_description_set_size(desc, (font.pointSizeF() > 0.0 ? font.pointSizeF() : QFontInfo(font).pointSizeF()) * PANGO_SCALE); + pango_font_description_set_family(desc, QFontInfo(font).family().toUtf8()); int weight = font.weight(); if (weight >= QFont::Black) -- cgit v1.2.3