Skip to content

fix(convertPathData): use relSubpoint, not .coords#2157

Open
KTibow wants to merge 4 commits intosvg:mainfrom
KTibow:dotcoords-is-bad
Open

fix(convertPathData): use relSubpoint, not .coords#2157
KTibow wants to merge 4 commits intosvg:mainfrom
KTibow:dotcoords-is-bad

Conversation

@KTibow
Copy link
Collaborator

@KTibow KTibow commented Jul 10, 2025

it turns out in the past i used item.coords (post-instruction coordinate in ORIGINAL svg) (resulting in incorrect calculations) when i should've been using relSubpoint; this switches to relSubpoint when fitting.

closes #2093

@KTibow
Copy link
Collaborator Author

KTibow commented Jul 11, 2025

the failing test cases are things like

<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 200 200">
<path d="M 78.301922,39.376734 L 64.971121,61.742246 L 73.061784,64.348229 L 78.512656,70.6691 L 84.285326,65.033743 L 92.451569,61.727261 L 78.301922,39.376734 z" fill="none" stroke="black" stroke-width="2"/>
</svg>

and the fail is because SVGO incorrectly rounds in a way that makes the start and end no longer connected

and the incorrectly coded "convert going home to z" logic was the only thing stopping the failure from surfacing

so fixing one thing shows another broken thing causes regressions... oh well i'll make a fix

@KTibow KTibow changed the title .coords is bad actually fix(convertPathData): use relSubpoint, not .coords Aug 12, 2025
folknor added a commit to folknor/svgo that referenced this pull request Feb 18, 2026
- Handle consecutive t commands properly (svg#2156)
  svg#2156
- Use relSubpoint for accurate post-rounding coordinates (svg#2157)
  svg#2157
- Introduce isSafeToRemove for smarter stroke-linecap handling (svg#2164)
  svg#2164

Note: reverted svg#2157's z-removal change (relSubpoint is already reset
to pathBase when z is processed, making the comparison always true).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.

The path minifier plugin isn't properly handling accumulated error

1 participant