[cairo] cairo_text_path() questions

hans at breuer.org hans at breuer.org
Fri Nov 9 11:02:32 PST 2007


>----Original Message----
>From: cworth at cworth.org
>Date: Nov 9, 2007 10:23 
>To: "Hans Breuer"<hans at breuer.org>
>Cc: <cairo at cairographics.org>
>Subj: Re: [cairo] cairo_text_path() questions
>

To answer the last question first: 
I'm implementing cairo based text outline rendering - with the ability 
to fill - for Dia's renderer interface [1]. The model is much less 
capable than cairo's but at the moment it supports way more more output 
formats including the ones of cairo [2] ;)

So I'm translating the text pathes given from cairo to DiaRenderer::
draw_bezier() and DiaRenderer::fill_bezier() calls.
It already works with Dia's current SVN but has the second issue from 
below. Just filling the outlines as they come puts the fill color even 
at places where holes are supposed to be.

>On Fri, 09 Nov 2007 17:46:21 +0100, Hans Breuer wrote:
>> Recently I've written a prototype for outline rendering with Dia 
based on
>> cairo_text_path(), see:
>
>Excellent. I hope cairo continues to work well for you.
>
>> 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.
>
>I suspect pilot error on this one. 
I'll try Behdad's suggestions.

>> 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.
>
>Cairo is just providing the glyph outlines exactly as they occur in
>the font.
>
>> Is there a way to detect the second outline being a hole in the 
glyph?
>
>Yes, that's what cairo_fill does, for example. It uses a
>scanline-based algorithm to evaluate the multiple paths and determine
>which points are inside and outside the final shape.
>
>But there's nothing to indicate that any particular sub-path is a
>"hole", 
Again I'll try to follow Behdad's suggestion or do you think it wont 
work?

> (and in fact, a single sub-path might be "subtracting" in one
>part and "adding" in some other part---though that requires
>intersecting sub-paths and hopefully fonts won't generally have
>those).
>
If the path is completely connected Dia's rendering should not have a 
problem. 
The thing I'm trying to solve is if I have the 'outer' outline or and 
a complete 
(unconnected) path just being a 'hole'.

>But anyway, the determination of "inside" and "outside" is a global
>question by definition. No local examination of any individual 
subpath
>can say anything about that.
>
>What is it you are trying to do that isn't working here? Perhaps we
>can help find some other answer for what you need.
>
See above.

Thanks,
    Hans


[1] http://svn.gnome.org/viewvc/dia/trunk/lib/diarenderer.h?
view=markup
[2] http://svn.gnome.org/viewvc/dia/trunk/plug-ins/cairo/diacairo.c?
view=markup



More information about the cairo mailing list