[cairo] Font interface problem

Maarten Breddels dmon at xs4all.nl
Tue Mar 9 10:31:10 PST 2004


Hello,

I think there are some problems with the current font interface. I've
started working on a win32 font backend, and encountered some problems.
The font backends only knows about the font matrix (which is multiplied
with the CTM before any call to the font backend). I think it's better
to pass the CTM as argument to the font backend because it is really
needed. Currently _cairo_gstate_text_extents does a bit of a fix to
change the device coordinates back to the user coordinates(allthough i'm
not sure if it's the right way, since it doesn't do rotation, which
'bearing' and 'advance' need). I also noticed
_cairo_gstate_current_font_extents doesn't try to transform the device
coordinates to user coordinates (is that a bug?).
And then there is a problem with glyphs, i think the cairo_glyph_t x and
y members are supposed to be in user coordinates, if so, the font
backend should know the CTM matrix to transform them to device
coordinates. Currently the FreeType2 backend treats the x and y members
of cairo_glyph_t as device coordinates, which i think is not the
expected behaviour from the user POV.
I noticed that the FreeType2 backend calculates the scale_x and scale_y
of the final matrix, and feeds it to FreeType2 for good hinting(since
ttf's don't have to scale linearly). If the CTM is passed as argument
to the font backend (and the font matrix implicitly trough the
cairo_font_t struct) i think it's better to use only the scale_x and
scale_y of the font matrix for hinting. This way scaling the CTM only
scales the font, and doesn't transform it, which is the expected
behaviour i think.
Another thing is that (0,0) is the upper left corner, with y going down
the screen, but fonts are mirrored in x, so they appear upright with an
unmodified CTM and font matrix. Allthough it's really usefull when
playing around with cairo for the first time, once you wanna do some
more advanced things it's really anoying the fonts are drawn upside
down, it just complicates things. Ok, it's not a big issue, but to keep
things simple, i think it's better to just draw them the 'normal' way.

Hope i've made myself clear,

Happy coding, Maarten
(I hope I didn't send it twice, otherwise blame Outlook :) )





More information about the cairo mailing list