[cairo] cairo_text_extents - imprecise width calculation?

Alexander Korban saskorban at yahoo.com
Tue Apr 19 14:06:19 PDT 2005


Hi

I'm using cairo under win32, and I noticed that
cairo_text_extents doesn't always return precise
results.
It seems that precision of the extents depends on font
scale (set using cairo_scale_font).

For example, with this code (I'm trying to center
text):

cairo_select_font(pCairo, "Tahoma",
CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_BOLD);
cairo_font_scale(0.6);
cairo_text_extents_t extents;
cairo_text_extents(pCairo, "OPEN", &extents);
cairo_move_to(pCairo, 0.5 - (extents.width / 2 +
extents.x_bearing), 0.5);
cairo_show_text(pCairo, "OPEN");

the text is off from the centered position to the
right
by about one character. However, when the font scale
is set to 0.65,
everything looks fine.

Could anyone give any suggestions please?

Best regards
Alex Korban.
-- 
Best regards
Alex Korban.


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 



More information about the cairo mailing list