[cairo] What are the unit of the height field in font_metrics_t?
Richard Cole
rcole at itee.uq.edu.au
Sat Oct 9 21:04:27 PDT 2004
Here is a program. Am I doing something wrong?
cairo_font_extents_t font_extents;
cairo_select_font (
cr, "Sans", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_BOLD
);
cairo_scale_font (cr, .3);
cairo_current_font_extents(cr, &font_extents);
cairo_save(cr);
cairo_move_to (cr, 0.04, 0.83);
cairo_show_text (cr, "Hello");
cairo_restore(cr);
cairo_save(cr);
cairo_set_line_width(cr, 0.01);
cairo_rectangle (cr,
0.04, 0.83 - font_extents.height, 0.5, font_extents.height);
fprintf(stderr, "TRACE: Font height=%f\n", font_extents.height);
fprintf(stderr, "TRACE: Font height * font_scale=%f\n",
font_extents.height * 0.3);
cairo_stroke(cr);
cairo_restore(cr);
I added this program to cairo-demo/cairo_snippets, ran make and then
"./cairo_snippets_png". The height being returned is: 89.400000, but the
font in the rendered image looks to be roughly 0.3 in user co-ordinates.
So what are the units of font_extents.height and how do I convert these
to user space? Is there any documentation, even a specification, of the
behaviour of the cairo_current_font_extents function?
regards,
Richard.
More information about the cairo
mailing list