[cairo] Paths and cairo_save()/restore()

Owen Taylor otaylor at redhat.com
Sat Jan 8 19:25:03 PST 2005


So, I was trying to write pango_cairo_layout_path(), which create a path
for an entire styled paragraph  of text, and it turned out to be hard.

In the parallel function pango_cairo_show_layout() I'm using 
cairo_save()/cairo_restore() so that I can change transform, current
font, etc. But you can't do that when constructing a path because 
save()/restore() save the path.

Talked to Carl about this some on IRC, and it seems like wanting
to save/restore when constructing paths is at least somewhat
common.

Possibilities:

 - Maybe cairo_save()/cairo_restore() shouldn't touch the path 
   at all. The PDF spec say:

   "(unlike PostScript), the current path is not part of the graphics
   state and is not saved and restored along with the other graphics
   state parameter"

   Disadvantage of this is:

   <cworth> A common PostScript/cairo idiom is: <construct path>; save;
     fill; restore; stroke; PDF works around this by adding a new
    drawing operator for fill_and_stroke, (and consequently two separate
    colors in the graphics state) -- very messy.

 - We could break out saving the path from cairo_save()/cairo_restore()
   into a separate function, and then you could use cairo_save_path()
   for the fill-and-stroke idiom.

 - We could have some sort of selective cairo_save()... along the
   lines of glPushAttrib() where you specify a bit mask for what
   you want to save.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
Url : http://lists.freedesktop.org/archives/cairo/attachments/20050108/d0b85529/attachment.pgp


More information about the cairo mailing list