Hi Albrecht,
On 11/21/2016 01:51:48 PM Mon, Albrecht Dreß wrote:
[re-sending with size and colour reduced screen shot]
Am 21.11.16 19:45 schrieb(en) Albrecht Dreß:
Hi all,
probably since commit 3ee5eb6ae773c0f3b847ed7355061919ba2d1421 or
8453c758ec619113441ce0011a387357c4c98b9b, the font sizes in Balsa are completely screwed up,
i.e. the "normal" font settings are now HUGE. Instead of the usual size 11, I now
have to select 8 to get roughly the same display as before. See attached screen shot, with
the font set to 10.5 in xfce's control panel (i.e. Balsa's std widgets), and 11 for the
message display - the font picker preview should be the same as the message header & body!
Note that I don't use the system fonts for Balsa's message display, as I want
monospace.
Any idea how to fix it?
Please try the attached patch. The issue is that the font button returns the
font size in points, and we have to convert that to pixels to generate CSS, and
the current code may be getting the display dpi wrong. I'm struggling with this!
Thanks,
Peter
diff --git a/libbalsa/misc.c b/libbalsa/misc.c
index d892a28..50c38d5 100644
--- a/libbalsa/misc.c
+++ b/libbalsa/misc.c
@@ -1369,7 +1369,8 @@ libbalsa_size_to_gchar(guint64 size)
gchar *
libbalsa_font_string_to_css(const gchar * font_string,
- const gchar * name)
+ const gchar * name,
+ GtkWidget * window)
{
PangoFontDescription *desc;
guint mask;
@@ -1377,6 +1378,7 @@ libbalsa_font_string_to_css(const gchar * font_string,
g_return_val_if_fail(font_string != NULL, NULL);
g_return_val_if_fail(name != NULL, NULL);
+ g_return_val_if_fail(window != NULL, NULL);
desc = pango_font_description_from_string(font_string);
mask = pango_font_description_get_set_fields(desc);
@@ -1454,12 +1456,17 @@ libbalsa_font_string_to_css(const gchar * font_string,
gint size;
size = pango_font_description_get_size(desc);
- if (!pango_font_description_get_size_is_absolute(desc))
- size *= gdk_screen_get_resolution(gdk_screen_get_default()) / 72;
+ if (!pango_font_description_get_size_is_absolute(desc)) {
+ g_message("size %d is not absolute", size);
+ size *= gdk_screen_get_resolution(gdk_window_get_screen(gtk_widget_get_window(window))) / 72;
+ } else {
+ g_message("size %d is absolute", size);
+ }
size = PANGO_PIXELS(size);
g_string_append_printf(string, "font-size: %dpx;\n", size);
}
g_string_append_c(string, '}');
+ g_message("CSS: \"%s\"", string->str);
pango_font_description_free(desc);
diff --git a/libbalsa/misc.h b/libbalsa/misc.h
index fc4d6fb..ebb2853 100644
--- a/libbalsa/misc.h
+++ b/libbalsa/misc.h
@@ -167,6 +167,8 @@ gchar *libbalsa_size_to_gchar(guint64 length);
gchar * libbalsa_text_to_html(const gchar * title, const gchar * body, const gchar * lang);
GString * libbalsa_html_encode_hyperlinks(GString * paragraph);
-gchar *libbalsa_font_string_to_css(const gchar * font_string, const gchar * name);
+gchar *libbalsa_font_string_to_css(const gchar * font_string,
+ const gchar * name,
+ GtkWidget * window);
#endif /* __LIBBALSA_MISC_H__ */
diff --git a/libbalsa/source-viewer.c b/libbalsa/source-viewer.c
index 208005f..eb89548 100644
--- a/libbalsa/source-viewer.c
+++ b/libbalsa/source-viewer.c
@@ -214,7 +214,8 @@ libbalsa_show_message_source(GtkApplication * application,
text = gtk_text_view_new();
gtk_widget_set_name(text, BALSA_SOURCE_VIEWER);
- css = libbalsa_font_string_to_css(font, BALSA_SOURCE_VIEWER);
+ window = gtk_application_window_new(application);
+ css = libbalsa_font_string_to_css(font, BALSA_SOURCE_VIEWER, window);
css_provider = gtk_css_provider_new();
gtk_css_provider_load_from_data(css_provider, css, -1, NULL);
@@ -234,7 +235,6 @@ libbalsa_show_message_source(GtkApplication * application,
GTK_POLICY_ALWAYS);
gtk_container_add(GTK_CONTAINER(interior), GTK_WIDGET(text));
- window = gtk_application_window_new(application);
gtk_window_set_title(GTK_WINDOW(window), _("Message Source"));
gtk_window_set_role(GTK_WINDOW(window), "message-source");
gtk_window_set_default_size(GTK_WINDOW(window), *width, *height);
diff --git a/src/balsa-mime-widget-message.c b/src/balsa-mime-widget-message.c
index 003c9a5..b1c3da6 100644
--- a/src/balsa-mime-widget-message.c
+++ b/src/balsa-mime-widget-message.c
@@ -574,7 +574,8 @@ add_header_gchar(GtkGrid * grid, const gchar * header, const gchar * label,
css = libbalsa_font_string_to_css(strcmp(header, "subject")
? balsa_app.message_font
: balsa_app.subject_font,
- BALSA_MESSAGE_HEADER);
+ BALSA_MESSAGE_HEADER,
+ GTK_WIDGET(balsa_app.main_window));
}
css_provider = gtk_css_provider_new();
diff --git a/src/balsa-mime-widget-text.c b/src/balsa-mime-widget-text.c
index 4e01557..2c56751 100644
--- a/src/balsa-mime-widget-text.c
+++ b/src/balsa-mime-widget-text.c
@@ -309,7 +309,8 @@ bm_modify_font_from_string(GtkWidget * widget, const char *font)
GtkCssProvider *css_provider;
gtk_widget_set_name(widget, BALSA_MESSAGE_TEXT_HEADER);
- css = libbalsa_font_string_to_css(font, BALSA_MESSAGE_TEXT_HEADER);
+ css = libbalsa_font_string_to_css(font, BALSA_MESSAGE_TEXT_HEADER,
+ GTK_WIDGET(balsa_app.main_window));
css_provider = gtk_css_provider_new();
gtk_css_provider_load_from_data(css_provider, css, -1, NULL);
diff --git a/src/sendmsg-window.c b/src/sendmsg-window.c
index 3ea776f..b11fa61 100644
--- a/src/sendmsg-window.c
+++ b/src/sendmsg-window.c
@@ -2303,7 +2303,8 @@ create_email_or_string_entry(BalsaSendmsg * bsmsg,
gtk_widget_set_name(arr[1], BALSA_COMPOSE_ENTRY);
css = libbalsa_font_string_to_css(balsa_app.message_font,
- BALSA_COMPOSE_ENTRY);
+ BALSA_COMPOSE_ENTRY,
+ GTK_WIDGET(balsa_app.main_window));
css_provider = gtk_css_provider_new();
gtk_css_provider_load_from_data(css_provider, css, -1, NULL);
@@ -2874,7 +2875,8 @@ create_text_area(BalsaSendmsg * bsmsg)
GtkCssProvider *css_provider;
css = libbalsa_font_string_to_css(balsa_app.message_font,
- BALSA_COMPOSE_ENTRY);
+ BALSA_COMPOSE_ENTRY,
+ GTK_WIDGET(balsa_app.main_window));
css_provider = gtk_css_provider_new();
gtk_css_provider_load_from_data(css_provider, css, -1, NULL);
_______________________________________________
balsa-list mailing list
[email protected]
https://mail.gnome.org/mailman/listinfo/balsa-list