[Cairo] Re: [xsvg] cairo_text_extents ?

Carl Worth cworth at east.isi.edu
Wed Dec 17 19:08:14 PST 2003

On Dec 16, Bill Spitzak wrote:
 > Here is the proposal again, reworded:

I'd like to ground this discussion by comparing the proposal to the
current cairo implementation.

 > There is a font_matrix with 4 numbers in it that is used to "scale" the font. 
 > This matrix is part of the cairo state

Currently, there is a font matrix in the cairo state. It contains 6

 > and the only things you can do to it are set it directly to 4
 > constants, or use grestore to go back to a previous value.

That sounds like the current font matrix. It can be set with
cairo_scale_font or cairo_transform_font. Calling cairo_restore will
restore it to its previous values.

 > The glyphs are transformed by the concatenation of this matrix and the 
 > current cairo transformation.

This is the case with the current code.

 > However this matrix does not contain x,y offsets, so the exact
 > position of the glyphs is not determined by it. Instead the font
 > itself gets to decide on these. It also can use this to modify the
 > extents information.

The cairo font matrix does contain translation values, but they are
not used to position the glyphs relative to each other. Instead, with
cairo_show_text, the current point is used as the origin of the first
glyph and subsequent glyphs are positioned according to the current
font and the transformations, (as you describe). cairo_show_glyphs
provides a mechanism for the user to manually position each individual

 > The "extents" contain a bounding box and ONLY an x_advance value.

The current cairo implementation has both x_advance and y_advance
values. But with only a freetype text backend implemented so far, it
looks like only one of these values will be non-zero.

So far, everything in the proposal is already contained in the current
cairo implementation, (although in a few cases cairo has fewer
restrictions or provides more information).

 > To produce vertical text, for a typical western font, you would rotate the 
 > cairo transform -90 and then set the font_transform to a +90 rotation. This 
 > would produce "sideways" glyphs that are moved so the origin of each of them 
 > is centered on the former top edge. The x_advance will have changed from the 
 > horizontal value to the vertical value.

This then is the only significant difference I see between this
proposal and the current cairo implementation.

 > I'm going to try to draw a diagram that shows this and put it on
 > the web...

Great. I'll follow up that message with more details then.


More information about the cairo mailing list