diff options
Diffstat (limited to 'common')
-rw-r--r-- | common/pango.c | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/common/pango.c b/common/pango.c index e8e2678d..e04bf80f 100644 --- a/common/pango.c +++ b/common/pango.c @@ -50,7 +50,7 @@ size_t escape_markup_text(const char *src, char *dest) { return length; } -PangoLayout *get_pango_layout(cairo_t *cairo, const char *font, +PangoLayout *get_pango_layout(cairo_t *cairo, const PangoFontDescription *desc, const char *text, double scale, bool markup) { PangoLayout *layout = pango_cairo_create_layout(cairo); PangoAttrList *attrs; @@ -73,16 +73,14 @@ PangoLayout *get_pango_layout(cairo_t *cairo, const char *font, } 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); pango_layout_set_single_paragraph_mode(layout, 1); pango_layout_set_attributes(layout, attrs); pango_attr_list_unref(attrs); - pango_font_description_free(desc); return layout; } -void get_text_size(cairo_t *cairo, const char *font, int *width, int *height, +void get_text_size(cairo_t *cairo, const PangoFontDescription *desc, int *width, int *height, int *baseline, double scale, bool markup, const char *fmt, ...) { va_list args; va_start(args, fmt); @@ -99,7 +97,7 @@ void get_text_size(cairo_t *cairo, const char *font, int *width, int *height, vsnprintf(buf, length, fmt, args); va_end(args); - PangoLayout *layout = get_pango_layout(cairo, font, buf, scale, markup); + PangoLayout *layout = get_pango_layout(cairo, desc, buf, scale, markup); pango_cairo_update_layout(cairo, layout); pango_layout_get_pixel_size(layout, width, height); if (baseline) { @@ -123,7 +121,7 @@ void get_text_metrics(const PangoFontDescription *description, int *height, int cairo_destroy(cairo); } -void render_text(cairo_t *cairo, const char *font, +void render_text(cairo_t *cairo, const PangoFontDescription *desc, double scale, bool markup, const char *fmt, ...) { va_list args; va_start(args, fmt); @@ -140,7 +138,7 @@ void render_text(cairo_t *cairo, const char *font, vsnprintf(buf, length, fmt, args); va_end(args); - PangoLayout *layout = get_pango_layout(cairo, font, buf, scale, markup); + PangoLayout *layout = get_pango_layout(cairo, desc, buf, scale, markup); cairo_font_options_t *fo = cairo_font_options_create(); cairo_get_font_options(cairo, fo); pango_cairo_context_set_font_options(pango_layout_get_context(layout), fo); |