[cairo] Tangential glyph enlargement

Maarten Bosmans mkbosmans at gmail.com
Tue May 10 07:30:00 PDT 2011


2011/5/10 Tobias Hoffmann <lcairo-list at thax.hardliners.org>:
> Hi!
>
> I'm using cairo (and freetype) to output some text, in bigger letters, and
> allowing effects like stroked outline + different fill color, etc.
> One parameter would then allow to draw the glyph a little bit bigger or
> smaller (and overlay this with itself, but unchanged size).
>
> But just using a bigger font_size for that is not what's really wanted.
> Strictly speaking, the glyph has to be "tangentially enlarged" (or shrunk).
> I'm currently using Cairo::Context::glyph_path().
>
> Is this possible/advisable to do with cairo (say, Cairo::Path), or should I
> try to grab the data from freetype and feed cairo with the modified path?
> Or is there still a better way?

The quick-n-dirty way is to just use a stroke. Let's say you want the
text enlarged by 10px and a stroke (outside of the enlarged glyphs) of
4px, then you draw a stroke of 28px in the stroke color, followed by a
stroke of 20px in the fill color and finally a fill.

Of course, actually directly using the stroke-to-patch Chris pointed
to will yield superior results, but in my experience, the above does
the trick reasonably well.

> Thanks,
>  Tobias

Maarten


More information about the cairo mailing list