[Cairo] Re: [xsvg] cairo_text_extents ?

Bill Spitzak spitzak at d2.com
Tue Nov 25 10:10:39 PST 2003


On Tuesday 25 November 2003 08:26 am, Carl Worth wrote:
> On Nov 21, John Ellson wrote:

> 	typedef struct {
> 	    double left_side_bearing;
> 	    double right_side_bearing;
> 	    double ascent;
> 	    double descent;
> 	    double x_advance;
> 	    double y_advance;
> 	} cairo_text_extents_t;
>
> Are the bearing values magnitudes or signed quantities? That is, which
> of the following calculations is correct:
>
> 	/* magnitudes */
> 	width = extents.right_side_bearing + extents.left_side_bearing;
>
> 	/* signed */
> 	width = extents.right_side_bearing - extents.left_side_bearing;
>
> Second, will the use of the names "left" and "right" behave in a sane
> fashion when subjected to transforms with reflection?
>
> Third, could we get by with shorter names here, eg. left and right?
> I'm having a hard time managing word wrap issues with equations like
> the one above, (eg. think trying to do "offset = width / 2.0" in one
> line).

Aren't "ascent" and "descent" sometimes different values that are supplied 
for the whole font? I think it may not be a good idea to use these numbers 
here.

My preference is to make everything signed and in the identical coordinate 
system, where 0,0 is the current text position on the baseline. The names can 
then be:

	left, bottom : coordinate of lower-left of bounding box
	top, right : coordinate of top-right of bounding box
	dx, dy : recommended origin for the next character

These numbers are usable directly by most math that has to work with 
characters and I think the resulting expressions are clearer.

I'm also in favor of having a current text transfomation matrix that is used 
to position all text, so that dy is always zero. This idea is apparently 
either being ignored or unpopular, but I will try to describe it again in 
another email.

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




More information about the cairo mailing list