diff options
author | emersion <contact@emersion.fr> | 2018-05-13 16:52:02 +0100 |
---|---|---|
committer | emersion <contact@emersion.fr> | 2018-05-13 16:52:02 +0100 |
commit | 6eda10e4ca1bfd0afe25f1255c42c0328b330a02 (patch) | |
tree | 5cdcaf054fe4d483307b5e6a005838ebcad93fdc | |
parent | 4dfb0529f865e9af327ea0740ae97f3d3e4da6f1 (diff) |
Fix pango markup
The condition checking if the markup is valid was inverted.
This commit also adds better error handling: if the markup cannot
be parsed, it fallbacks to plain text.
-rw-r--r-- | common/pango.c | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/common/pango.c b/common/pango.c index 9437c60d..403bd9a8 100644 --- a/common/pango.c +++ b/common/pango.c @@ -77,19 +77,21 @@ PangoLayout *get_pango_layout(cairo_t *cairo, const char *font, if (markup) { char *buf; GError *error = NULL; - bool result = pango_parse_markup(text, -1, 0, &attrs, &buf, - NULL, &error); - if (result) { + if (pango_parse_markup(text, -1, 0, &attrs, &buf, NULL, &error)) { + pango_layout_set_markup(layout, buf, -1); + free(buf); + } else { wlr_log(L_ERROR, "pango_parse_markup '%s' -> error %s", text, error->message); - return NULL; + g_error_free(error); + markup = false; // fallback to plain text } - pango_layout_set_markup(layout, text, -1); - free(buf); - } else { + } + if (!markup) { attrs = pango_attr_list_new(); pango_layout_set_text(layout, text, -1); } + pango_attr_list_insert(attrs, pango_attr_scale_new(scale)); PangoFontDescription *desc = pango_font_description_from_string(font); pango_layout_set_font_description(layout, desc); |