mirror of
https://github.com/swaywm/sway.git
synced 2025-01-17 08:28:01 +01:00
Merge pull request #1971 from emersion/fix-pango-markup
Fix pango markup
This commit is contained in:
commit
364439cc11
1 changed files with 9 additions and 7 deletions
|
@ -77,19 +77,21 @@ PangoLayout *get_pango_layout(cairo_t *cairo, const char *font,
|
||||||
if (markup) {
|
if (markup) {
|
||||||
char *buf;
|
char *buf;
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
bool result = pango_parse_markup(text, -1, 0, &attrs, &buf,
|
if (pango_parse_markup(text, -1, 0, &attrs, &buf, NULL, &error)) {
|
||||||
NULL, &error);
|
pango_layout_set_markup(layout, buf, -1);
|
||||||
if (result) {
|
|
||||||
wlr_log(L_ERROR, "pango_parse_markup '%s' -> error %s", text,
|
|
||||||
error->message);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
pango_layout_set_markup(layout, text, -1);
|
|
||||||
free(buf);
|
free(buf);
|
||||||
} else {
|
} else {
|
||||||
|
wlr_log(L_ERROR, "pango_parse_markup '%s' -> error %s", text,
|
||||||
|
error->message);
|
||||||
|
g_error_free(error);
|
||||||
|
markup = false; // fallback to plain text
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!markup) {
|
||||||
attrs = pango_attr_list_new();
|
attrs = pango_attr_list_new();
|
||||||
pango_layout_set_text(layout, text, -1);
|
pango_layout_set_text(layout, text, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
pango_attr_list_insert(attrs, pango_attr_scale_new(scale));
|
pango_attr_list_insert(attrs, pango_attr_scale_new(scale));
|
||||||
PangoFontDescription *desc = pango_font_description_from_string(font);
|
PangoFontDescription *desc = pango_font_description_from_string(font);
|
||||||
pango_layout_set_font_description(layout, desc);
|
pango_layout_set_font_description(layout, desc);
|
||||||
|
|
Loading…
Reference in a new issue