Skip to content

SVG: draw nothing for a <circle> without r or a <polyline> or <polygon> without points - #2168

Merged
andersonhc merged 3 commits into
py-pdf:masterfrom
RavSinghChandan:svg-shape-missing-attributes
Nov 12, 2026
Merged

andersonhc merged 3 commits into
py-pdf:masterfrom
RavSinghChandan:svg-shape-missing-attributes

Conversation

@RavSinghChandan

Copy link
Copy Markdown

A <circle> without r, and a <polyline> or <polygon> without points, fail with a KeyError. In the SVG specification the initial value of r is 0, which disables rendering, and a missing points is an empty list of points, so these elements draw nothing. fpdf2 already does that for an <ellipse> without rx and ry, and for points="".

A circle without r comes up with SMIL animations, where the radius is only set by an <animate attributeName="r" .../> child, for example a pulsing ring:

<circle cx="260" cy="255" fill="none" stroke="#0071e3" stroke-width="5">
  <animate attributeName="r" values="113;119;113" dur="2.5s" repeatCount="indefinite"/>
</circle>

circle() now reads a missing r as 0 and returns an empty path for r="0", like ellipse(); polyline() and polygon() read a missing points as "". Before, r="0" drew a degenerate circle, which can show as a dot with a round-capped stroke.

The circle no r, polyline no points and polygon no points cases of test_svg_shape_tags expected the KeyError; they now expect no path, and a new circle r 0 case is added. All four fail on master. The SVG tests, black and pylint pass

@andersonhc
andersonhc merged commit a37b748 into py-pdf:master Nov 12, 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