[cairo] API: cairo_set_current_point()

Behdad Esfahbod behdad at behdad.org
Wed Sep 3 05:32:53 PDT 2008

Chris Wilson wrote:
> Hi all,
>  I'd like to propose this new bit of API to move the current point
> without generating a new sub-path: cairo_set_current_point(). My
> motivation is from implementing PostScript operators (and type1 fonts,
> in particular, depend heavily on this operation). However, it is exactly
> the same operation required by Inkscape for its path optimisation,
> see http://lists.cairographics.org/archives/cairo/2008-April/013651.html
> and the most recent reminder.

I like this.

Speaking of Postscript, do you feel like implementing cairo_save_path() and


>>From the Type1 documentation, I have a couple of instances where I need
> to explicitly adjust the current point without creating a new path:
> closepath -
> 	closepath closes a subpath. ... Note that, unlike
> 	the closepath command in the PostScript language, this com-
> 	mand does not reposition the current point. Any subsequent
> 	rmoveto must be relative to the current point in force before
> 	the Type 1 font format closepath command was given.
> sbw -
> 	sets the left sidebearing point to (sbx, sby) and sets the
> 	character width vector to (wx, wy) in character space. This
> 	command also sets the current point to (sbx, sby), but does not
> 	place the point in the character path. Use rmoveto for the first
> 	point in the path.
> [Though because of the explicit rmovetos, they fortuitously work with
> cairo_move_to().]
> setcurrentpoint -
> 	sets the current point in the Type 1 font format
> 	BuildChar to (x, y) in absolute character space coordinates
> 	without performing a charstring moveto command. This establishes
> 	the current point for a subsequent relative path building
> 	command. 
> In terms of how I think it works...
> cairo_set_current_point() updates the current point, setting the
> has_current_point flag so future relative operations do not fail. The
> current use of has_current_point is restricted to the relative
> operations as the origin of their deltas and a (new last_point,
> has_last_point) is introduced to track what is currently referred to as
> current_point. That is a line_to() after set_current_point(), performs a
> move_to() (and similar effects for curve_to() and arc()) and
> close_path() does nothing if has_current_point, but not has_last_point
> is set. And paths are only equal if the last_point and not current_point
> are the same.
> They say a patch speaks a thousand words...
> ------------------------------------------------------------------------
> _______________________________________________
> cairo mailing list
> cairo at cairographics.org
> http://lists.cairographics.org/mailman/listinfo/cairo

More information about the cairo mailing list