[cairo] Font interface problem

Maarten Breddels dmon at xs4all.nl
Tue Mar 9 13:21:02 PST 2004


> Please feel free to re-work backend interfaces as necessary to get
> things working.

Ok

> A larger concern of mine is fixing bugs in the user-visible portion of
> the API. There are problems that I've already found,
> (eg. cairo_scale_font modifies fonts that the user previously grabbed
> via cairo_current_font). Also, there are some ambiguities in the
> current interface that need to be nailed down. Some of these will
> require experience from developers trying to use cairo in non-trivial
> applications.

>  > 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?).
> 
> Your descriptions sound like bugs. If you can generate minimal test
> cases to demonstrate the problems, that would help,
> (cairo-demo/png/text.c might be a good starting point). Of course,
> even better would be patches to fix the bugs.

I'll try to do both.

>  > 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,
> 
> Yes.
> 
>  > 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.
> 
> Yes, the default graphics convention is for Y to increase from
> top-down, while the default font convention is for Y to increase from
> bottom-up. This leads to plenty of confusion at the boundary of these
> two systems, (such as cairo_text_extents). Concrete proposals to
> address the problem would be quite helpful.
> 
>  > Ok, it's not a big issue, but to keep things simple, i think it's
>  > better to just draw them the 'normal' way.
> 
> Could you describe more specifically what you would like to change
> here?

Well, to use a convention that sounds simple, so if y goes down, the
fonts should also be upside down(y going down). Or have (0,0) at the
lower left corner, and make y go up, and fonts upright.
What I normally do is:
 cairo_scale(cr, 1, -1)
 cairo_translate(cr, 0, -height);
But using the current convention, the fonts will be upside down, and I
can't say for sure in a moment what the signs are for all the font and
glyph extents(positive or negative?). This convention just complicates
matters.

So I suggest that the fonts are drawn with y the same direction as the y
on the surface(user coordinates), I don't really care where (0,0) is, I
suggest you leave it where it is.

And, do you agree that fonts drawn with:
  cairo_scale(2,2)
  cairo_scale_font(2)
Are '4' (whatever units) high, but it's a font of height 2, linearly
scaled 2 times in x in y.
While:
  cairo_scale(1,1)
  cairo_scale_font(4)
Is a font of height 4, and isn't scaled.
It matters(not that much though) because ttf(truetype fonts) are
transformed (not necessarily linear) at different sizes to keep them
readable. Currently they are both drawn as 4 units high, not scaled in
any way.

Greetings, Maarten :)





More information about the cairo mailing list