[Cairo] Re: [xsvg] cairo_text_extents ?
Christof Petig
christof at petig-baender.de
Thu Dec 4 00:46:34 PST 2003
Bill Spitzak schrieb:
> 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
> output.
The only problem I might feign is a mixture of right to left and left to
right characters (e.g. numbers in hebrew text IIRC). ;-)
> 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.
This solves the problem (and seems to be not that alien for right to
left users). Though I susect problems with said Nastaliq.
IMHO you should only make sure that a decent solution will not need a
redesign of the API. Everything else should be left to the point where
arabic programmers voice concrete problems/solutions.
---------
> 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.
I have some problems to imagine a circular arc which passes dx,0 dx,dy
and 0,dy and has it's maximum distance at dx,dy.
How do you calculate dy for a normal font?
> 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
> values.
correct.
Perhaps a rect is even better than an ellipse.
> Another alternative is a straight line between dx,0 and 0,dy.
Easier to implement but will perhaps overlap glyphs more likely.
> 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.
I did not know that a horizontal font can provide a vertical advance
(for drawing it vertically). And I suspect the most common fonts do not
provide it (e.g. Helvetica,Vera).
So my proposal was to stack them according to their bounding box (plus
some space inbetween) which should give a reasonable look. Perhaps
constant 1.6 ex even looks more reasonable. But using x_advance to stack
letters atop will suck (circular approach).
Christof
More information about the cairo
mailing list