[cairo] Font pixel height
Andreas Falkenhahn
andreas at falkenhahn.com
Tue Aug 9 10:10:23 UTC 2022
Hi,
strictly speaking this question is about Pango but since I didn't find a Pango mailing list and I use Cairo to render my Pango layouts I hope it's ok to ask this question here :)
I want to create a font that uses a specific pixel height, so I do something like this:
fontmap = pango_cairo_font_map_new();
fontdesc = pango_font_description_from_string("Liberation 144px");
context = pango_font_map_create_context(fontmap);
font = pango_font_map_load_font(fontmap, context, fontdesc);
m = pango_font_get_metrics(font, NULL);
height = pango_font_metrics_get_height(m) / PANGO_SCALE;
Surprisingly, "height" is now 167 even though I requested a font height of 144 pixels. Is there any way to create a font whose pixel height is exactly or at least closely what I requested? Currently, there seems to be a rather significant deviation from the requested pixel size and the actual pixel height, e.g. I'm getting a font whose height is 167 pixels when requesting a 144 pixel font.
Thanks!
--
Best regards,
Andreas Falkenhahn mailto:andreas at falkenhahn.com
More information about the cairo
mailing list