[cairo] cairo_select_font() (was: cairo_scale_font/cairo_transform_font())

Øyvind Kolås islewind at gmail.com
Sat Mar 19 10:45:52 PST 2005


On Sat, 19 Mar 2005 13:27:56 -0500, Owen Taylor <otaylor at redhat.com> wrote:
>  cairo_select_font (cr, "Sans",
>                     CAIRO_FONT_SLANT_NORMAL,
>                     CAIRO_FONT_WEIGHT_NORMAL);
>  cairo_scale_font (cr, 10); /* 10 pt font */
>  cairo_scale_font (cr, 12); /* 120 pt font */
> 
> To:
> 
>  cairo_select_font (cr, "Sans",
>                     CAIRO_FONT_SLANT_NORMAL,
>                     CAIRO_FONT_WEIGHT_NORMAL);
>  cairo_set_font_size (cr, 10); /* 10 pt font */
>  cairo_set_font_size (cr, 12); /* 12 pt font */

IMHO this change makes the api more useful and easier to understand,
(I am assuming a %s/pt/user space units/g ),

> But if there was a getter, it would not change with the CTM. The CTM and
> font matrix are entirely independent entities.

Ok, this would make it possible to act upon the current font object
from a binding. I'd also like to split out the components of the
"FontName", making a coding style like:

cr.font.name = "Sans"
cr.font.slant = Cairo::FONT_SLANT_ITALIC
cr.font.size = 12

possible in for instance the ruby binding.

Splitting out the slant and weight components, also reduces the amount
of code needed in the default case (and a lookup in the API to figure
out the allowed values), as well as reduce the amount of forced line
wraps (the rest of the drawing api seems to seldom reach column 40.)

/Øyvind K.

-- 
Software patents hinder progress | http://swpat.ffii.org/ 
Web :  http://pippin.gimp.org/



More information about the cairo mailing list