fix: start new cairo subpath before drawing aperture holes#380
fix: start new cairo subpath before drawing aperture holes#380spe-ciellt merged 1 commit intogerbv:developfrom
Conversation
Without cairo_new_sub_path(), Cairo connects the hole subpath to the outer aperture shape with an implicit line segment. This causes rendering artifacts on annular ring pads and any aperture with a drilled hole. Add cairo_new_sub_path() in gerbv_draw_aperture_hole() so the hole is drawn as an independent subpath, matching the expected winding- rule cutout behavior. Regenerate 10 affected golden test images. Extracted from gerbv#163.
Cosmetic
/* skip first point, since we've moved there already */
/* include last point, since we may be drawing an aperture hole next
and cairo may not correctly close the path itself */
for (i = 1; i <= (int)numberOfSidesInteger; i++) {
...
cairo_line_to(...); /* deliberately repeats the first vertex */
}This comment (and the loop bound The loop bound change would be a separate correctness question (closing vs. |
The loop in gerbv_draw_polygon ran i <= numberOfSidesInteger (inclusive) to repeat the first vertex as a zero-length closing segment. The comment explained this was needed because cairo might draw a spurious line from the polygon endpoint to the start of an aperture hole subpath. PR gerbv#380 fixed the root cause by adding cairo_new_sub_path() in gerbv_draw_aperture_hole(), which starts a fresh subpath before drawing any hole — severing the implicit connection entirely. With that fix in place the extra vertex is dead code. Remove it and the now-inaccurate comment. No functional change; golden images are unaffected. Closes gerbv#433.
Summary
Without
cairo_new_sub_path(), Cairo connects the hole subpath to the outer aperture shape with an implicit line segment. This causes rendering artifacts on annular ring pads and any aperture with a drilled hole.cairo_new_sub_path()call ingerbv_draw_aperture_hole()before drawing the hole shape, so the hole is rendered as an independent subpathAttribution
Extracted from #163 (@meantaipan).
Test plan
cmake --preset linux-gnu-gcc && cmake --build build— clean buildctest -C Debug— 94/105 pass (11 pre-existing mismatches, unchanged from develop)