[Cairo] Re: [xsvg] cairo_text_extents ?
spitzak at d2.com
Wed Dec 3 14:07:54 PST 2003
On Wednesday 03 December 2003 12:17 am, Christof Petig wrote:
> I see the problem. (I do not understand yet which coordinate system will
> be used - but I trust your design, it simply _sounds_ well thought out!)
New explanation: Changing the font_matrix will change what values are
returned by the extents calls. Changing the text_matrix will *not* change
> Please do not envision a text API which does not work well with arabic
> (right to left) or CJK scripts (can be top to bottom)! Sadly I don't
> know enough about it to judge.
For backwards text, I believe my scheme would also allow you to send a
font_matrix that mirrors horizontally. Similar to the rotation changing the
origin and x_advance to the vertical sizes, this must alter the position of
the letters and negate the x_advance (so it is positive again) so when you
draw glyphs in reading-order you get a mirror-image of the Hebrew/Arabic
text. You can then use a text_transform that mirrors it back and get proper
Alternatively you can just send the glyphs in backwards order. I think this
is a common solution already and will be very popular, one advantage is that
"stupid" programs (like cat) will produce readable output, it also makes it a
lot easier to mix languages, or to format bi-directional fonts, because you
don't have to change the text_matrix. Notice that the x_advance of
Hebrew/Arabic letters is positive in all cases.
For CJK, from what little I know, there are *no* languages left that *only*
draw vertically. All of them have a horizontal option. Therefore I think it
is acceptable that vertical be "difficult" because it allows horizontal to be
so much simpler. Most CJK is also laid out on a very neat grid that is not
really controlled by "extents" and thus could easily be drawn by sending an
x,y position with every glyph, and ignoring all the rotation stuff.
> > No, the x_advance value will be set to produce the correct spacing. If a
> > font actually contains "vertical advance" information, this is simply
> > used as the horizontal advance when 90 degree rotation is selected. If
> > you don't use
> you mean character rotation here - right?
> If I imagine proportinal fonts I clearly get strange results. What do
> you think about the elliptical/bounding box proposal?
It may be better.
If the advance vector is plotted on the unrotated letter and moved so the
origins all lined up, what I described is a circular arc that passes through
dx,0 and dx,dy and 0,dy and the maximum advance is the point at dx,dy.
What you descirbe I think is an axis-aligned quarter ellipse, with the center
at the origin and passing through dx,0 and 0,dy. The maximum advance is at
either the horiztonal or vertical, all other advances are between these
Another alternative is a straight line between dx,0 and 0,dy.
Your idea may be best. Or something between any of these ideas, or a more
complex shape. However I think also the decision can be left up to the fonts,
each can make it's own rules.
,~,~,~,~ ~ ~ ~ ~
/\_ _|_========___ Bill Spitzak
~~~/\/\\~~~~~~\____________/~~~~~~~~ spitzak at d2.com
More information about the cairo