Skip to content

drawing: omit an arc whose end point is its start point, like SVG - #2132

Merged
andersonhc merged 1 commit into
py-pdf:masterfrom
RavSinghChandan:arc-identical-endpoints
Nov 9, 2026
Merged

andersonhc merged 1 commit into
py-pdf:masterfrom
RavSinghChandan:arc-identical-endpoints

Conversation

@RavSinghChandan

Copy link
Copy Markdown

An SVG path with an arc that ends where it starts, such as M10 10 A5 5 0 0 0 10 10, made pdf.image() fail with ZeroDivisionError: float division by zero in Arc._approximate_arc(). The same happened for PaintedPath.arc_to() back to the current point.

The SVG specification says such an arc is omitted ("If the endpoints are identical, then this is equivalent to omitting the elliptical arc segment entirely", SVG 1.1 F.6.2). _approximate_arc() now returns no curves for it, and Arc.render() already draws nothing for an empty list.

Added two cases to svg_path_render_tests (absolute and relative arc); they fail on master with the ZeroDivisionError.

  • A unit test is covering the code added / modified by this PR
  • A mention of the change is present in CHANGELOG.md
  • This PR is ready to be merged

@andersonhc
andersonhc merged commit a4edd4a into py-pdf:master Nov 9, 2026
23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants