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.
This commit is contained in:
Hombre 2016-12-25 17:56:57 +01:00
parent 19cabcb9b2
commit adb2ec1241
2 changed files with 12 additions and 0 deletions

View File

@ -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());

View File

@ -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 (...) {