如何重置开罗的当前点?

How to reset the current point in cairo?

从 cairo 文档中,我可以看到一些功能,例如 Text toy-API cairo_show_text() 需要设置当前点。 我们可以用 cairo_move_to() 设置当前点,然后调用 cairo_show_text() 它将光栅化所需位置的文本。

顺便说一句,这导致了一个错误,因为在光栅化文本之后,我正在抚摸一条路径,该路径(最初调用 cairo_move_to() 来设置文本的当前点)有错误的点。

我在调用 cairo_show_text() 后立即调用 cairo_stroke() 解决了这个错误,它似乎有效,因为它重置了当前点。

似乎调用 cairo_close_path() 而不是 cairo_stroke() 没有帮助。它没有重置当前点。我认为这很奇怪。为什么?

我的最后一个问题是:有没有正确的方法来重置当前点?我觉得应该有。

来自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.

完整性:还有这个函数不清除当前路径:

来自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 the cairo_arc() calls. This makes things easier as it is no longer necessary to manually compute the arc's initial coordinates for a call to cairo_move_to().