17 char *fontdescription,
int fontsize,
18 double *width,
double *height)
20 PangoFontMap *fontmap;
22 int pango_width, pango_height;
25 fontmap = pango_cairo_font_map_get_default();
27 if (!pango_parse_markup
30 PangoContext *
const context = pango_font_map_create_context(fontmap);
31 layout = pango_layout_new(context);
32 g_object_unref(context);
33 pango_layout_set_text(
layout, text, -1);
35 PangoFontDescription *
const desc =
36 pango_font_description_from_string(fontdescription);
37 pango_font_description_set_size(desc, (
int)(fontsize * PANGO_SCALE));
38 pango_layout_set_font_description(
layout, desc);
41 pango_font_description_free(desc);
42 pango_layout_set_alignment(
layout, PANGO_ALIGN_CENTER);
44 pango_layout_get_size(
layout, &pango_width, &pango_height);
46 *width = (double) pango_width / PANGO_SCALE;
47 *height = (double) pango_height / PANGO_SCALE;
54 cairo_surface_t **surface,
int *w,
66 *surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, (
int)width,
69 cairo_t *cr = cairo_create(*surface);
71 cairo_set_source_rgba(cr, 1, 1, 1, 1);
73 pango_cairo_show_layout(cr,
layout);
82 return cairo_image_surface_get_data(*surface);
unsigned char * glCompCreatePangoTexture(char *fontdescription, int fontsize, const char *txt, cairo_surface_t **surface, int *w, int *h)
static PangoLayout * get_pango_layout(const char *markup_text, char *fontdescription, int fontsize, double *width, double *height)