[cairo] Font interface problem

Maarten Breddels dmon at xs4all.nl
Tue Mar 9 16:45:44 PST 2004


> -----Original Message-----
> From: cairo-admin at cairographics.org 
> [mailto:cairo-admin at cairographics.org] On Behalf Of Bill Spitzak
> Sent: dinsdag 9 maart 2004 23:43
> To: Maarten Breddels; 'Carl Worth'
> Cc: cairo at cairographics.org
> Subject: Re: [cairo] Font interface problem
> 
> 
> On Tuesday 09 March 2004 01:21 pm, Maarten Breddels wrote:
> 
> > And, do you agree that fonts drawn with:
> >   cairo_scale(2,2)
> >   cairo_scale_font(2)
> > Are '4' (whatever units) high, but it's a font of height 2, linearly
> > scaled 2 times in x in y.
> > While:
> >   cairo_scale(1,1)
> >   cairo_scale_font(4)
> > Is a font of height 4, and isn't scaled.
> > It matters(not that much though) because ttf(truetype fonts) are
> > transformed (not necessarily linear) at different sizes to keep them
> > readable. Currently they are both drawn as 4 units high, 
> not scaled in
> > any way.
> 
> 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.

> There should be seperate arguments to the font selector 
> interface to indicate 
> "draw as though you are N points tall". This is much more 
> similar to setting 
> the weight or other attributes of the font than to scaling.
> 
> There could be a "simple" font choosing interface that takes 
> a "size" and 
> sets the font matrix to that size and also sets the "draw as 
> though you are N 
> points tall" to the same value (or that value*96/72 to turn 
> Cairo units into 
> points on the assumption that the CTM is the default matrix). 
> But internally 
> this should be seperated as fast as possible.

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.

> PLEASE don't make the mistake of specifying the size of the 
> font in "points" 
> or any unit other than the CTM units. This makes it 
> impossible to produce 
> predictable graphics unless I go in and retrieve exactly how 
> you map pionts 
> to font matricies and then calculate the inverse, a total 
> waste of time on 
> everybody's part. If I want to take advantage of a font 
> renderer that draws 
> differently depending on the points, you should use a fixed 
> and predictable 
> way of turning the size into "points" (such as assumming that 
> the CTM is 
> 1/96), or let me independently specify this "points" value, 
> since I know the 
> "point size" much better than Cairo does (I may be trying to 
> actually draw a 
> reduced-size image of the paper, for instance).

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).

Greetings from .nl, Maarten





More information about the cairo mailing list