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) { | |||
50 | return length; | 50 | return length; |
51 | } | 51 | } |
52 | 52 | ||
53 | PangoLayout *get_pango_layout(cairo_t *cairo, const char *font, | 53 | PangoLayout *get_pango_layout(cairo_t *cairo, const PangoFontDescription *desc, |
54 | const char *text, double scale, bool markup) { | 54 | const char *text, double scale, bool markup) { |
55 | PangoLayout *layout = pango_cairo_create_layout(cairo); | 55 | PangoLayout *layout = pango_cairo_create_layout(cairo); |
56 | PangoAttrList *attrs; | 56 | PangoAttrList *attrs; |
@@ -73,16 +73,14 @@ PangoLayout *get_pango_layout(cairo_t *cairo, const char *font, | |||
73 | } | 73 | } |
74 | 74 | ||
75 | pango_attr_list_insert(attrs, pango_attr_scale_new(scale)); | 75 | pango_attr_list_insert(attrs, pango_attr_scale_new(scale)); |
76 | PangoFontDescription *desc = pango_font_description_from_string(font); | ||
77 | pango_layout_set_font_description(layout, desc); | 76 | pango_layout_set_font_description(layout, desc); |
78 | pango_layout_set_single_paragraph_mode(layout, 1); | 77 | pango_layout_set_single_paragraph_mode(layout, 1); |
79 | pango_layout_set_attributes(layout, attrs); | 78 | pango_layout_set_attributes(layout, attrs); |
80 | pango_attr_list_unref(attrs); | 79 | pango_attr_list_unref(attrs); |
81 | pango_font_description_free(desc); | ||
82 | return layout; | 80 | return layout; |
83 | } | 81 | } |
84 | 82 | ||
85 | void get_text_size(cairo_t *cairo, const char *font, int *width, int *height, | 83 | void get_text_size(cairo_t *cairo, const PangoFontDescription *desc, int *width, int *height, |
86 | int *baseline, double scale, bool markup, const char *fmt, ...) { | 84 | int *baseline, double scale, bool markup, const char *fmt, ...) { |
87 | va_list args; | 85 | va_list args; |
88 | va_start(args, fmt); | 86 | va_start(args, fmt); |
@@ -99,7 +97,7 @@ void get_text_size(cairo_t *cairo, const char *font, int *width, int *height, | |||
99 | vsnprintf(buf, length, fmt, args); | 97 | vsnprintf(buf, length, fmt, args); |
100 | va_end(args); | 98 | va_end(args); |
101 | 99 | ||
102 | PangoLayout *layout = get_pango_layout(cairo, font, buf, scale, markup); | 100 | PangoLayout *layout = get_pango_layout(cairo, desc, buf, scale, markup); |
103 | pango_cairo_update_layout(cairo, layout); | 101 | pango_cairo_update_layout(cairo, layout); |
104 | pango_layout_get_pixel_size(layout, width, height); | 102 | pango_layout_get_pixel_size(layout, width, height); |
105 | if (baseline) { | 103 | if (baseline) { |
@@ -123,7 +121,7 @@ void get_text_metrics(const PangoFontDescription *description, int *height, int | |||
123 | cairo_destroy(cairo); | 121 | cairo_destroy(cairo); |
124 | } | 122 | } |
125 | 123 | ||
126 | void render_text(cairo_t *cairo, const char *font, | 124 | void render_text(cairo_t *cairo, const PangoFontDescription *desc, |
127 | double scale, bool markup, const char *fmt, ...) { | 125 | double scale, bool markup, const char *fmt, ...) { |
128 | va_list args; | 126 | va_list args; |
129 | va_start(args, fmt); | 127 | va_start(args, fmt); |
@@ -140,7 +138,7 @@ void render_text(cairo_t *cairo, const char *font, | |||
140 | vsnprintf(buf, length, fmt, args); | 138 | vsnprintf(buf, length, fmt, args); |
141 | va_end(args); | 139 | va_end(args); |
142 | 140 | ||
143 | PangoLayout *layout = get_pango_layout(cairo, font, buf, scale, markup); | 141 | PangoLayout *layout = get_pango_layout(cairo, desc, buf, scale, markup); |
144 | cairo_font_options_t *fo = cairo_font_options_create(); | 142 | cairo_font_options_t *fo = cairo_font_options_create(); |
145 | cairo_get_font_options(cairo, fo); | 143 | cairo_get_font_options(cairo, fo); |
146 | pango_cairo_context_set_font_options(pango_layout_get_context(layout), fo); | 144 | pango_cairo_context_set_font_options(pango_layout_get_context(layout), fo); |