[cairo] Change font as well as line to be in device space
spitzak at d2.com
Fri May 5 16:00:42 PDT 2006
Carl Worth wrote:
> Additionally there is the possibility of a slight change in the
> semantics of cairo_set_line_width. We believe the current behavior of the sequence:
> cairo_set_line_width; ... change CTM ...; cairo_stroke;
> is buggy. It is currently behaving the same as:
> ... change CTM ...; cairo_set_line_width; cairo_stroke;
> We are considering fixing this bug before 1.2 with the hope that
> nobody is already relying on the buggy behavior described here. Do
> shout if you suspect you might be in that position.
Any chance of also doing this for the current font? This is probably a
more important change, and I believe it will be far more useful than the
line width one. I suspect it may get rid of the need for all the
variations on scaled/unscaled internal font types and confusion about
how hinting is applied. It would also make the usage of fonts match the
lines and patterns, which seems desirable. I also believe this is going
to be necessary if 3D transforms are ever to be considered.
Here is a more detailed description of what I'm thinking of:
Once you set a font, the glyphs will draw exactly the same shapes from
then on on the output device, no matter what you do with the CTM. The
CTM in effect when the font was set is remembered as the "font CTM".
Any font metrics are returned in the font CTM. That is, the results do
not change no matter what you do to the CTM, just like now.
The draw_glyphs function acts exactly like the current one would if you
changed the CTM by replacing the first 4 numbers with the font CTM. This
produces the same output as today if the CTM is unchanged or if only
translations have been done. To layout a string starting at x,y, code
should translate to x,y, then use the font metrics to figure out all the
positions starting at 0,0 for the glyphs.
Code that wants to draw boxes around or strikeouts through letters, or
hand-draw glyphs, will need the addition of a call to replace the first
4 numbers of the CTM with the font CTM. They can surround this with
gsave and grestore, and also do a translate to put 0,0 at the desired
"origin". Without this call such code will not work if the CTM is
changed between the font and drawing, but this does not produce the
correct output now, so no loss.
More information about the cairo