[cairo] Want to stretch my fonts
Krzysztof Kosiński
tweenk.pl at gmail.com
Wed Jul 28 09:26:50 PDT 2010
2010/7/28 Kayven Riese <kayvey at gmail.com>:
> but that takes only cr as an argument.. so it is going to scale my entire
> canvas right? I need to learn to make my letters on a different canvas and
> combine the two canvases or something, don't I?
cairo_scale and related calls do not scale the canvas. They only
affect how the coordinates you give to cairo_move_to, cairo_line_to,
etc. are interpreted. If you scale non-uniformly it will also affect
how the stroke is drawn.
> The attached pngs are cellgram.png with line 86 commented out.. and the
> other file with the cairo_matrix_init_scale active.. I am seeing a
> translation instead of a vertical shear .. or.. umm.. I wanted to squish the
> word so it would fit in the cell. I just wanted to do some numerical
> experiments (hence just plugged in 0.8 and 1).. what am I missing?
The text *is* squeezed vertically, but the initial font matrix also
contained a translation. By clearing the matrix and initializing it
with a scale, you are removing it. I'll post an explanation of what
you need to do to obtain the correct result in a few minutes.
> Do the scale factors multiply or add? I am supply sy = 0.. maybe I want sy
> = 1
The scale factors always multiply. Zero X scale means nothing will be
visible because your drawing will be collapsed to a vertical line.
> But if I restore the context, have I done anything? It seems if I restore
> the context I will lose the changes I am trying to make.
cairo_save and cairo_restore save and restore the current
transformation matrix and clip region, they do not save / restore
canvas contents. Everything you draw (using cairo_stroke, cairo_fill,
cairo_paint, etc.) between cairo_save and cairo_restore stays on the
canvas. Paths are also preserved. Take a look at section "Working with
Transforms" here:
http://cairographics.org/tutorial/
Regards, Krzysztof
More information about the cairo
mailing list