[cairo] API: cairo_set_current_point()
chris at chris-wilson.co.uk
Wed Sep 3 02:18:46 PDT 2008
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,
and the most recent reminder.
>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 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.
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
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
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...
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 0 bytes
Url : http://lists.cairographics.org/archives/cairo/attachments/20080903/30a52772/attachment.bin
More information about the cairo