From adb2ec124195d45fe42cddf45c48b68d3ac5567a Mon Sep 17 00:00:00 2001 From: Hombre Date: Sun, 25 Dec 2016 17:56:57 +0100 Subject: [PATCH] Fix font size from FontButton, behave differently from Gtk3.18 vs. 3.20 Gtk3.18 use px unit, Gtk3.20 use pt unit. Font selection does not necessarily select the correct font where variant exists, expect strange result. Nothing will be done to fix that. --- rtgui/main.cc | 6 ++++++ rtgui/preferences.cc | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/rtgui/main.cc b/rtgui/main.cc index 4d4406c37..f27a0f32f 100644 --- a/rtgui/main.cc +++ b/rtgui/main.cc @@ -338,7 +338,13 @@ int main(int argc, char **argv) if (options.fontFamily != "default") { try { cssForced = Gtk::CssProvider::create(); + //GTK318 + #if GTK_MAJOR_VERSION == 3 && GTK_MINOR_VERSION < 20 + cssForced->load_from_data (Glib::ustring::compose("* { font-family: %1; font-size: %2px }", options.fontFamily, options.fontSize)); + #else cssForced->load_from_data (Glib::ustring::compose("* { font-family: %1; font-size: %2pt }", options.fontFamily, options.fontSize)); + #endif + //GTK318 Gtk::StyleContext::add_provider_for_screen(screen, cssForced, GTK_STYLE_PROVIDER_PRIORITY_APPLICATION); } catch (Glib::Error &err) { printf("Error: \"%s\"\n", err.what().c_str()); diff --git a/rtgui/preferences.cc b/rtgui/preferences.cc index e96dd3f69..96c1941b5 100644 --- a/rtgui/preferences.cc +++ b/rtgui/preferences.cc @@ -2112,7 +2112,13 @@ void Preferences::switchFontTo(const Glib::ustring &newFontFamily, const int new } try { + //GTK318 + #if GTK_MAJOR_VERSION == 3 && GTK_MINOR_VERSION < 20 + fontcss->load_from_data (Glib::ustring::compose("* { font-family: %1; font-size: %2px }", newFontFamily, newFontSize)); + #else fontcss->load_from_data (Glib::ustring::compose("* { font-family: %1; font-size: %2pt }", newFontFamily, newFontSize)); + #endif + //GTK318 } catch (Glib::Error &err) { printf("Error: \"%s\"\n", err.what().c_str()); } catch (...) {