[cairo] PDF type3 font support; Just bugs to fix before cairo 1.2

Bill Spitzak spitzak at d2.com
Tue May 16 13:33:48 PDT 2006

Behdad Esfahbod wrote:

> Ok, that simplifies the implementation then.  We just need to
> keep the font space matrix and divide by the current CTM in
> cairo_get_font_matrix().  Oh, and so the same reasoning means
> that cairo_text/glyph_extents() will return values in user space,
> so one doesn't really need to know what the CTM at the time of
> setting font matrix was.  No new API needed.  Or do you see any
> other uses Bill?

I think you are right, this is an excellent idea. Returning the metrics 
in user space would be much more consistent with the rest of Cairo and 
avoids questions about how to use glyph metrics.

[My previous thinking was that the glyph metrics would be returned in 
the font CTM. The main reason was to simplify and speed up the glyph 
metrics calls, as the results are constant no matter what the fontCTM or 
current CTM are. Also it would allow non-affine CTMs (but I think that 
may break so much other stuff that it could not be done anyway)]

Since the escapement has both an x & y value the vector can be 
transformed by fontCTM times the inverse of the CTM. I think bounding 
boxes should preserve the area, being only correct if the rotation is a 
multiple of 90 degrees, unless the font backend really can figure out 
the close-fit rectangle. Using the bounding box of the transformed 
bounding box corners results in far too large of an area.

I suspect this is identical to what you are proposing:

set_font_matrix() would multiply the provided matrix by the CTM and that 
would be the font matrix.

get_font_matrix() would divide the font matrix by the CTM and return that.

set_font_size() would be the same as set_font_matrix with [s,0,0,s].

get_font_size() would return the square root of the determinant of the 
font CTM divided by the CTM. set_font_size(get_font_size()) would work 
for transformations and uniform scales.

More information about the cairo mailing list