clip_preserve()-related drawing bug on Windows
The sample Python code below draws this on a Mac using pycairo 1.20.1 and cairo 1.16.0 (installed via Homebrew):

On Windows using pycairo 1.20.0 and 1.20.1 (installed via pip using the Windows wheel), it draws this:

import cairo
WIDTH, HEIGHT = 400, 400
surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, WIDTH, HEIGHT)
ctx = cairo.Context(surface)
ctx.scale(WIDTH, HEIGHT)
points = [[200, 100], [222.45139882897308, 169.09830056251377], [295.10565162951536, 169.09830056250527], [236.32712640025804, 211.80339887498624], [258.7785252292473, 280.90169943749476], [200.0, 238.196601125], [141.22147477075268, 280.9016994374947], [163.67287359974196, 211.80339887498624], [104.89434837048466, 169.09830056250522], [177.54860117102692, 169.09830056251377]]
ctx.new_path()
ctx.move_to(points[0][0] / WIDTH, points[0][1] / HEIGHT)
for point in points[1:]:
ctx.line_to(point[0] / WIDTH, point[1] / HEIGHT)
ctx.close_path()
ctx.set_source_rgb(1, 0 ,0)
ctx.fill_preserve()
ctx.clip_preserve()
ctx.set_source_rgb(0, 1, 0)
ctx.set_line_width(.05)
ctx.stroke()
surface.write_to_png("example.png")
Any ideas what might be causing this? Let me know if I can provide any more information that would be helpful.
Any ideas what might be causing this?
The wheels are packaged with cairo version 1.17.2. I could only think of that being a problem. Probably it would be better to ask cairo mailing list about this.
+1 on asking on the cairo mailinglist, in general they are very helpful - and if this is a bug in cairo itself, they will definitely want to know.
I think most of the people here are on that list as well :)
Also, FYI this is what I get with your code
On Arch linux, Cairo Version 1.17.4 and Pycairo 1.20.1.
So I guess something is wrong with the version distributed in wheels?
Thanks for the suggestion. I'll keep investigating and email the cairo mailing list soon.
I see that there is now a 1.17.4 release of Cairo, with lots of fixes, including changes to the Windows build process. Is it possible/easy to make a new release of https://github.com/preshing/cairo-windows that uses 1.17.4?
I think cairo version 1.17.4 uses meson build system, so it should be easy to build it ourselves. But that would mean we would be distributing a development release, is it fine @lazka?
yes, ideally we should update to the snapshot, and port our cairo build to meson