[Cairo] Re: [xsvg] cairo_text_extents ?

Bill Spitzak spitzak at d2.com
Tue Dec 30 10:19:22 PST 2003


On Wednesday 17 December 2003 07:34 pm, Carl Worth wrote:

> It occurred to me that I didn't know for sure how cairo used the CTM
> and font matrix when dealing with relative placement within
> cairo_show_text. So, I wrote a little program to find out. It's in CVS
> at cairo-demo/png/text-rotate.c. The resulting image can be seen at:
>
> http://cairographics.org/~cworth/download/text-rotate.png

This image shows how I expected it works. Certainly this makes sense and is 
simple to describe. My concern is that the interface, as designed now, 
provides a y_advance value that any program calling it must be prepared for 
this to be non-zero. Also the fact that currently no fonts are producing 
non-zero for both x_advance and y_advance means that calling programs are 
unprepared for this case. I would greatly prefer if the y_advance was 
eliminated so that calling programs know this case cannot happen.

My initial idea was to simply eliminate one number from the font matrix so 
that rotations were impossible, only scale, skew, and translate. Vertical 
text would be selected much like it is now (by another flag to the font) but 
would produce "sideways" letters so that the x_advance could still contain 
useful information.

After reading some of the feedback I came up with this idea where rotations 
are allowed and the rotation is then used to select vertical layout.

It is quite possible that my idea is a big waste of time and only horizontal 
and vertical layout would ever be selected, diagonal may require too much 
control over individual glyph positions.

Perhaps my original proposal where selecting a vertical font produced the 
sideways letters would be easier to do. Another possibility is to just 
document the fact that at no time will x_advance and y_advance both be 
non-zero and that which one is non-zero is the same for all glyphs in a font. 
This could also be enforced by putting the advances into the same field and 
having some other indicator as to whether the font is horizontal or vertical.

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




More information about the cairo mailing list