From 352234f35fb40c586f4188c208edd851ed6eab6b Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Tue, 13 Jun 2023 07:08:57 +0300 Subject: [PATCH 24/24] gtk: Set font size unit correctly Reported by skywind3000 See osdn #48185 Signed-off-by: Marko Lindqvist --- client/gui-gtk-3.0/gui_stuff.c | 9 +++++++-- client/gui-gtk-3.22/gui_stuff.c | 9 +++++++-- client/gui-gtk-4.0/gui_stuff.c | 9 +++++++-- 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/client/gui-gtk-3.0/gui_stuff.c b/client/gui-gtk-3.0/gui_stuff.c index ac17d1056a..ec46e86857 100644 --- a/client/gui-gtk-3.0/gui_stuff.c +++ b/client/gui-gtk-3.0/gui_stuff.c @@ -1041,8 +1041,13 @@ void gui_update_font(const char *font_name, const char *font_value) size = pango_font_description_get_size(desc); if (size != 0) { - str = g_strdup_printf("#Freeciv #%s { font-family: %s; font-size: %dpx;%s%s}", - font_name, fam, size / PANGO_SCALE, style, weight); + if (pango_font_description_get_size_is_absolute(desc)) { + str = g_strdup_printf("#Freeciv #%s { font-family: %s; font-size: %dpx;%s%s}", + font_name, fam, size / PANGO_SCALE, style, weight); + } else { + str = g_strdup_printf("#Freeciv #%s { font-family: %s; font-size: %dpt;%s%s}", + font_name, fam, size / PANGO_SCALE, style, weight); + } } else { str = g_strdup_printf("#Freeciv #%s { font-family: %s;%s%s}", font_name, fam, style, weight); diff --git a/client/gui-gtk-3.22/gui_stuff.c b/client/gui-gtk-3.22/gui_stuff.c index cf9f38fedf..3805da15fb 100644 --- a/client/gui-gtk-3.22/gui_stuff.c +++ b/client/gui-gtk-3.22/gui_stuff.c @@ -1040,8 +1040,13 @@ void gui_update_font(const char *font_name, const char *font_value) size = pango_font_description_get_size(desc); if (size != 0) { - str = g_strdup_printf("#Freeciv #%s { font-family: %s; font-size: %dpx;%s%s}", - font_name, fam, size / PANGO_SCALE, style, weight); + if (pango_font_description_get_size_is_absolute(desc)) { + str = g_strdup_printf("#Freeciv #%s { font-family: %s; font-size: %dpx;%s%s}", + font_name, fam, size / PANGO_SCALE, style, weight); + } else { + str = g_strdup_printf("#Freeciv #%s { font-family: %s; font-size: %dpt;%s%s}", + font_name, fam, size / PANGO_SCALE, style, weight); + } } else { str = g_strdup_printf("#Freeciv #%s { font-family: %s;%s%s}", font_name, fam, style, weight); diff --git a/client/gui-gtk-4.0/gui_stuff.c b/client/gui-gtk-4.0/gui_stuff.c index 8db941eb8c..b6860aeb13 100644 --- a/client/gui-gtk-4.0/gui_stuff.c +++ b/client/gui-gtk-4.0/gui_stuff.c @@ -973,8 +973,13 @@ void gui_update_font(const char *font_name, const char *font_value) size = pango_font_description_get_size(desc); if (size != 0) { - str = g_strdup_printf("#Freeciv #%s { font-family: %s; font-size: %dpx;%s%s}", - font_name, fam, size / PANGO_SCALE, style, weight); + if (pango_font_description_get_size_is_absolute(desc)) { + str = g_strdup_printf("#Freeciv #%s { font-family: %s; font-size: %dpx;%s%s}", + font_name, fam, size / PANGO_SCALE, style, weight); + } else { + str = g_strdup_printf("#Freeciv #%s { font-family: %s; font-size: %dpt;%s%s}", + font_name, fam, size / PANGO_SCALE, style, weight); + } } else { str = g_strdup_printf("#Freeciv #%s { font-family: %s;%s%s}", font_name, fam, style, weight); -- 2.39.2