[cairo] font scaling

Phil Blundell pb at nexus.co.uk
Sun Nov 14 07:48:40 PST 2004


It seems that cairo_select_font() only sets an identity scaling matrix
if the newly-selected font is different to the current font.  This
causes surprising results with code like:

cairo_select_font (cr, "Sans", CAIRO_FONT_SLANT_NORMAL,
CAIRO_FONT_WEIGHT_NORMAL);
cairo_scale_font (cr, 11.0);
cairo_show_text (cr, "This is size 11.");

cairo_select_font (cr, "Sans", CAIRO_FONT_SLANT_NORMAL,
CAIRO_FONT_WEIGHT_NORMAL);   /* Same as before */
cairo_scale_font (cr, 11.0);
cairo_show_text (cr, "But this is size 121!");

I'm assuming this behaviour is not deliberate.  The attached patch seems
to clear it up for me.

As an aside, if you have a third iteration of this process, allowing the
size to reach 1331, any attempt to render text leads to an assertion
failure in _cairo_cache_lookup because the allocated block for a single
glyph exceeds the maximum size that was set for the entire glyph cache.

Thanks

p.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: cairo-font.patch
Type: text/x-patch
Size: 646 bytes
Desc: not available
Url : http://lists.freedesktop.org/archives/cairo/attachments/20041114/687c90b5/cairo-font.bin


More information about the cairo mailing list