[Cairo] Re: [xsvg] cairo_text_extents ?
Bill Spitzak
spitzak at d2.com
Tue Dec 16 14:46:58 PST 2003
On Tuesday 16 December 2003 01:47 pm, Owen Taylor wrote:
> The Pango approach is going to be that lines of text always
> proceed in the positive-X direction. Vertical text will involve
> a 90 degree rotation of Han characters during layout so they
> get rotated back into vertical by the overall matrix.
Notice that this matches my proposal exactly.
Here is the proposal again, reworded:
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, 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.
The glyphs are transformed by the concatenation of this matrix and the
current cairo transformation. 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 "extents" contain a bounding box and ONLY an x_advance value.
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 would also support diagonal layout in a clean way.
I'm going to try to draw a diagram that shows this and put it on the web...
--
,~,~,~,~ ~ ~ ~ ~
/\_ _|_========___ Bill Spitzak
~~~/\/\\~~~~~~\____________/~~~~~~~~ spitzak at d2.com
More information about the cairo
mailing list