Normalize SF Symbol variant paths for interpolation compatibility#123
Open
rursache wants to merge 1 commit intoswhitty:mainfrom
Open
Normalize SF Symbol variant paths for interpolation compatibility#123rursache wants to merge 1 commit intoswhitty:mainfrom
rursache wants to merge 1 commit intoswhitty:mainfrom
Conversation
When generating SF Symbols with separate weight variants (ultralight, regular, black), the source SVGs can have incompatible path structures - different segment counts or types (e.g. a cubic curve in one weight where another has a straight line). SF Symbols requires identical path structures across all variants for interpolation. This fix adds a two-phase normalization after variant paths are generated: 1. Segment count alignment: When one variant has an extra segment (e.g. a rounded corner as cubic where others have a sharp corner), degenerate zero-length cubic segments are inserted in the shorter variants to match the longest. 2. Type promotion: When variants have the same number of segments but different types at a position (line vs cubic), lines are promoted to degenerate cubic curves with control points along the line. Closes swhitty#57
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
L(line) to degenerateC(cubic) where types differ at the same positionExample (from the reported issue):
Before fix:
After fix:
Test plan
testNormalizeSegments_PromotesLineToCubic- verifies L→C promotiontestNormalizeSegments_InsertsDegenerate- verifies alignment with extra segmentstestNormalizeSegments_AlreadyMatching- verifies no-op when paths matchtestCommandTypeandtestPromoteToCubicunit tests for helpersphoto.errorSVGs - all 3 variants produce matching segment sequencesCloses #57