[cairo] cairo_text_path() questions

Behdad Esfahbod behdad at behdad.org
Fri Nov 9 10:05:08 PST 2007


On Fri, 2007-11-09 at 11:46 -0500, Hans Breuer wrote:
> Recently I've written a prototype for outline rendering with Dia based on
> cairo_text_path(), see:
> http://svn.gnome.org/viewvc/dia/trunk/objects/standard/outline.c?view=markup
> 
> There are two things which make it less useful than expected:
> 
> 1) although there is a cario context required to call cairo_text_path() the
> transformation within it seems to be ignored (or I am doing something
> wrong:)) E.g. calling cairo_rotate() before cairo_text_path() does not have
> the desired effect of delivering a rotated path.

It works.  But if you do cairo_text_path() and cairo_copy_path() with
the same matrix, you always get the same result.  What you want to do is
to rotate before cairo_text_path, but go back to identity (or whatever)
before cairo_copy_path().


> 2) cairo is delivering multiple closed pathes per glyph. If for example one
> renders '#' the first path given describes the outer curve while the next
> closed path gives the inner square.
> Is there a way to detect the second outline being a hole in the glyph?

I don't think there is.  This is how fonts are defined.  You probably
can detect it.  All holes have different orientation than non-holes.
One set are clockwise, the other counterclockwise.  That's very easy to
check:

  - Find the point on path with least y.  If many have that same y, take
the one with the least x.

  - Take it's two (degenerate) neighbors.  Compute the slope to those,
using atan2.

  - Compare the slopes and decide whether it's CW or CCW.


behdad


> This is tested with cairo 1.4.10 on Windows and Linux, the results are
> consistent across the different font backends.
> 
> Thanks,
> 	Hans
> 
> -------- Hans "at" Breuer "dot" Org -----------
> Tell me what you need, and I'll tell you how to
> get along without it.                -- Dilbert
> _______________________________________________
> cairo mailing list
> cairo at cairographics.org
> http://lists.cairographics.org/mailman/listinfo/cairo
-- 
behdad
http://behdad.org/

"Those who would give up Essential Liberty to purchase a little
 Temporary Safety, deserve neither Liberty nor Safety."
        -- Benjamin Franklin, 1759





More information about the cairo mailing list