[cairo] Font interface problem

Bill Spitzak spitzak at d2.com
Tue Mar 9 17:52:58 PST 2004


On Tuesday 09 March 2004 04:45 pm, Maarten Breddels wrote:

> > I think fonts should be drawn identically for a given
> > transform, no matter
> > what portion of that transform is in the CTM and what part is
> > in the font
> > transformation.
>
> Are you sure, this would make things like zooming impossible. I know I'm
> splitting hairs here, and it's convenient if it works like you are
> describing here, but it is limiting cairo. I don't wanna make a big deal
> out if, but I might be worth discussing about.

What I meant is that for a given result of multiplying the CTM and font 
matrix together the result should be equal. If you zoom in, the result of 
mulitplying the matricies also zooms in.

What I want is if one of the matricies is the identity, and you swap them, 
the output should be identical.

> Yes, good idea, sth like cairo_set_font_size(12), and you should get 12
> point high font, only depending on your 'pixels_per_inch'. It could also
> look at the CTM to make a matching font matrix.
>
> Ofcourse, when the font matrix scales 40x40, and CTM is set to the
> identity matrix, the font should be 40 pixels high on a raster display,
> instead of 40 'points', whatever that size may be.
> Btw, cairo_gstate_t has a pixels_per_inch member, so that will define
> the size of the font(pixelheight=pixels_per_inch*pointsize/72).

This is what I thought at first, but it looks like it would be better to have 
the "point size" be determined directly as a constant multiplier of the font 
size selected. This is so if you scale the drawing the letter widths do not 
change.

What I am proposing is:

"complex" font interface: takes a Font Matrix which literally changes the 
transformation of the letter forms by the exact linear transformation 
specified. The Complex interface also takes a lot of other arguments, such as 
the font name, weight, slant, and other controls, one of which can be "point 
size". Point size can be used by the font renderer to alter the shapes of the 
letters so that *if* they are scaled to that given point size they look 
correct.

"simple" interface: takes a "size" and sets the FontMatrix to (size,0,0,size) 
and sets the point size to size*72/96 points. The assumption is that anybody 
using the "simple" interface has left the CTM alone, but this allows drawings 
using the simple interface to be scaled and imbedded into other drawings 
without the letter widths changing.

Point size is probably unrelated to raster hinting. I think the renderer can 
alter the final bitmap based on the actual current transform so that the 
pictures are clearer. Font metricies probably should not change, I would 
instead render each letter at several different fractional pixel positions 
and select the nearest one, so that renderings truly scale.

-- 
                   ,~,~,~,~ ~ ~ ~ ~
     /\_       _|_========___         Bill Spitzak
 ~~~/\/\\~~~~~~\____________/~~~~~~~~ spitzak at d2.com




More information about the cairo mailing list