Skip to content

Implement SVG path optimizations and add BezPath iterator - #104

Open
joshi-07 wants to merge 1 commit into
googlefonts:mainfrom
joshi-07:issue-18-29-optimizations
Open

joshi-07 wants to merge 1 commit into
googlefonts:mainfrom
joshi-07:issue-18-29-optimizations

Conversation

@joshi-07

Copy link
Copy Markdown

This commit addresses issues #18 and #29:

Issue #18 - Enhanced SVG path optimizations:

  • Collapse repeated horizontal and vertical lines into single commands
  • Convert degenerate quadratic and cubic curves to lines
  • Drop leading zeros from decimal numbers (0.5 -> .5, -0.3 -> -.3)
  • Existing optimizations (relative coords, smooth curves, nop removal) preserved

Issue #29 - Added PathWithPosIter:

  • New iterator that tracks current position while iterating path elements
  • Returns PathElWithPos containing element, current position, and subpath start
  • Eliminates code duplication between Unchanged and Compact path styles
  • Both path styles now use the shared iterator for position tracking

The changes maintain backward compatibility while adding the requested functionality.

@google-cla

google-cla Bot commented Sep 20, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

This commit addresses issues googlefonts#18 and googlefonts#29:

Issue googlefonts#18 - Enhanced SVG path optimizations:
- Collapse repeated horizontal and vertical lines into single commands
- Convert degenerate quadratic and cubic curves to lines
- Drop leading zeros from decimal numbers (0.5 -> .5, -0.3 -> -.3)
- Existing optimizations (relative coords, smooth curves, nop removal) preserved

Issue googlefonts#29 - Added PathWithPosIter:
- New iterator that tracks current position while iterating path elements
- Returns PathElWithPos containing element, current position, and subpath start
- Eliminates code duplication between Unchanged and Compact path styles
- Both path styles now use the shared iterator for position tracking

The changes maintain backward compatibility while adding the requested functionality.
@joshi-07
joshi-07 force-pushed the issue-18-29-optimizations branch from 79ce334 to 958200f Compare September 20, 2026 05:33
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.

1 participant