From cairo documentation, I can see that some functions, for instance the Text toy-API cairo_show_text()
needs a current point to be set.
We can set the current point with cairo_move_to()
, and then calling cairo_show_text()
it will rasterize the text in the desired location.
Btw, this caused a bug, because after rasterizing text, I was stroking a path, which (with that initial call to cairo_move_to()
to set the current point for the text) had wrong points.
I solved this bug by calling cairo_stroke()
immediately after calling cairo_show_text()
, and it seems to work, since it resets the current point.
It seems that calling cairo_close_path()
instead of cairo_stroke()
hasn't been helpful. It didn't reset the current point. And I think this is quite strange. Why?
My final question is: is there a proper way to reset the current point? I think there should be.
From https://www.cairographics.org/manual/cairo-Paths.html#cairo-new-path
cairo_new_path ()
Clears the current path. After this call there will be no path and no current point.
For completeness: There is also this function which does not clear the current path:
From https://www.cairographics.org/manual/cairo-Paths.html#cairo-new-sub-path
cairo_new_sub_path ()
Begin a new sub-path. Note that the existing path is not affected. After this call there will be no current point.
In many cases, this call is not needed since new sub-paths are frequently started with cairo_move_to().
A call to
cairo_new_sub_path()
is particularly useful when beginning a new sub-path with one of thecairo_arc()
calls. This makes things easier as it is no longer necessary to manually compute the arc's initial coordinates for a call tocairo_move_to()
.