[evolution/gnome-41] I#1571 - Broken font settings can break message display
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution/gnome-41] I#1571 - Broken font settings can break message display
- Date: Tue, 7 Dec 2021 11:41:55 +0000 (UTC)
commit 3a4e0c8832e828c8908c8082e6e9684fe292e8f1
Author: Milan Crha <mcrha redhat com>
Date: Tue Dec 7 12:30:55 2021 +0100
I#1571 - Broken font settings can break message display
Closes https://gitlab.gnome.org/GNOME/evolution/-/issues/1571
src/e-util/e-web-view.c | 22 ++++++++++++++++++++--
src/modules/webkit-editor/e-webkit-editor.c | 20 ++++++++++++++++----
2 files changed, 36 insertions(+), 6 deletions(-)
---
diff --git a/src/e-util/e-web-view.c b/src/e-util/e-web-view.c
index 1115ab8e9b..9ab13b69cc 100644
--- a/src/e-util/e-web-view.c
+++ b/src/e-util/e-web-view.c
@@ -3327,7 +3327,7 @@ e_web_view_update_fonts_settings (GSettings *font_settings,
"monospace-font-name");
ms = pango_font_description_from_string (
- (font != NULL) ? font : "monospace 10");
+ (font && *font) ? font : "monospace 10");
clean_ms = TRUE;
@@ -3335,6 +3335,15 @@ e_web_view_update_fonts_settings (GSettings *font_settings,
} else
ms = ms_font;
+ if (!pango_font_description_get_family (ms) ||
+ !pango_font_description_get_size (ms)) {
+ if (clean_ms)
+ pango_font_description_free (ms);
+
+ clean_ms = TRUE;
+ ms = pango_font_description_from_string ("monospace 10");
+ }
+
if (!vw_font) {
gchar *font;
@@ -3343,7 +3352,7 @@ e_web_view_update_fonts_settings (GSettings *font_settings,
"font-name");
vw = pango_font_description_from_string (
- (font != NULL) ? font : "serif 10");
+ (font && *font) ? font : "serif 10");
clean_vw = TRUE;
@@ -3351,6 +3360,15 @@ e_web_view_update_fonts_settings (GSettings *font_settings,
} else
vw = vw_font;
+ if (!pango_font_description_get_family (vw) ||
+ !pango_font_description_get_size (vw)) {
+ if (clean_vw)
+ pango_font_description_free (vw);
+
+ clean_vw = TRUE;
+ vw = pango_font_description_from_string ("serif 10");
+ }
+
stylesheet = g_string_new ("");
g_ascii_dtostr (fsbuff, G_ASCII_DTOSTR_BUF_SIZE,
((gdouble) pango_font_description_get_size (vw)) / PANGO_SCALE);
diff --git a/src/modules/webkit-editor/e-webkit-editor.c b/src/modules/webkit-editor/e-webkit-editor.c
index 4312d7f739..1042cc1bcd 100644
--- a/src/modules/webkit-editor/e-webkit-editor.c
+++ b/src/modules/webkit-editor/e-webkit-editor.c
@@ -1179,25 +1179,31 @@ webkit_editor_update_styles (EContentEditor *editor)
if (use_custom_font) {
font = g_settings_get_string (
wk_editor->priv->mail_settings, "monospace-font");
- ms = pango_font_description_from_string (font ? font : "monospace 10");
+ ms = pango_font_description_from_string (font && *font ? font : "monospace 10");
g_free (font);
} else {
font = g_settings_get_string (
wk_editor->priv->font_settings, "monospace-font-name");
- ms = pango_font_description_from_string (font ? font : "monospace 10");
+ ms = pango_font_description_from_string (font && *font ? font : "monospace 10");
g_free (font);
}
+ if (!pango_font_description_get_family (ms) ||
+ !pango_font_description_get_size (ms)) {
+ pango_font_description_free (ms);
+ ms = pango_font_description_from_string ("monospace 10");
+ }
+
if (wk_editor->priv->html_mode) {
if (use_custom_font) {
font = g_settings_get_string (
wk_editor->priv->mail_settings, "variable-width-font");
- vw = pango_font_description_from_string (font ? font : "serif 10");
+ vw = pango_font_description_from_string (font && *font ? font : "serif 10");
g_free (font);
} else {
font = g_settings_get_string (
wk_editor->priv->font_settings, "font-name");
- vw = pango_font_description_from_string (font ? font : "serif 10");
+ vw = pango_font_description_from_string (font && *font ? font : "serif 10");
g_free (font);
}
} else {
@@ -1205,6 +1211,12 @@ webkit_editor_update_styles (EContentEditor *editor)
vw = pango_font_description_copy (ms);
}
+ if (!pango_font_description_get_family (vw) ||
+ !pango_font_description_get_size (vw)) {
+ pango_font_description_free (vw);
+ vw = pango_font_description_from_string ("serif 10");
+ }
+
stylesheet = g_string_new ("");
g_ascii_dtostr (fsbuff, G_ASCII_DTOSTR_BUF_SIZE,
((gdouble) pango_font_description_get_size (vw)) / PANGO_SCALE);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]