Skip to content

Commit

Permalink
Merge pull request #936 from thejan2009/pango-numeric-char-ref
Browse files Browse the repository at this point in the history
parse pango markup in workspace names (and bugfix)
  • Loading branch information
ddevault authored Oct 7, 2016
2 parents fa11966 + 6f2c396 commit 77433f0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
4 changes: 2 additions & 2 deletions swaybar/render.c
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ void workspace_button_size(struct window *window, const char *workspace_name, in
const char *stripped_name = strip_workspace_name(swaybar.config->strip_workspace_numbers, workspace_name);

get_text_size(window->cairo, window->font, width, height,
window->scale, false, "%s", stripped_name);
window->scale, true, "%s", stripped_name);
*width += 2 * ws_horizontal_padding;
*height += 2 * ws_vertical_padding;
}
Expand Down Expand Up @@ -241,7 +241,7 @@ static void render_workspace_button(struct window *window, struct config *config
cairo_set_source_u32(window->cairo, box_colors.text);
cairo_move_to(window->cairo, (int)*x + ws_horizontal_padding, margin);
pango_printf(window->cairo, window->font, window->scale,
false, "%s", stripped_name);
true, "%s", stripped_name);

*x += width + ws_spacing;
}
Expand Down
6 changes: 4 additions & 2 deletions wayland/pango.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@ PangoLayout *get_pango_layout(cairo_t *cairo, const char *font, const char *text
int32_t scale, bool markup) {
PangoLayout *layout = pango_cairo_create_layout(cairo);
PangoAttrList *attrs = pango_attr_list_new();
char *buf = malloc(2048);
if (markup) {
pango_parse_markup(text, -1, 0, &attrs, NULL, NULL, NULL);
pango_layout_set_markup(layout, text, -1);
pango_parse_markup(text, -1, 0, &attrs, &buf, NULL, NULL);
pango_layout_set_markup(layout, buf, -1);
} else {
pango_layout_set_text(layout, text, -1);
}
Expand All @@ -24,6 +25,7 @@ PangoLayout *get_pango_layout(cairo_t *cairo, const char *font, const char *text
pango_layout_set_attributes(layout, attrs);
pango_attr_list_unref(attrs);
pango_font_description_free(desc);
free(buf);
return layout;
}

Expand Down

0 comments on commit 77433f0

Please sign in to comment.