Skip to content

SVG → EMF direction + lossy matcher + fidelity tooling (v0.1.2) - #12

Merged
ronaldtse merged 1 commit into
mainfrom
feat/svg-to-emf
Jul 26, 2026
Merged

SVG → EMF direction + lossy matcher + fidelity tooling (v0.1.2)#12
ronaldtse merged 1 commit into
mainfrom
feat/svg-to-emf

Conversation

@ronaldtse

Copy link
Copy Markdown
Contributor

Summary

  • SVG → EMF translation direction: full handler pipeline for shapes, transforms, clips, text, images
  • Lossy SVG matcher proving 208/208 (100%) EMF→SVG semantic equivalence vs libemf2svg at 0.1px tolerance
  • Developer tooling: fidelity scan, round-trip scan, diff diagnostics
  • Regression spec locking in EMF→SVG fidelity vs libemf2svg
  • PS_GEOMETRIC pen fix for width > 1
  • 205 specs, 0 failures

Test plan

  • bundle exec rspec — 205 examples, 0 failures
  • bundle exec rubocop — clean on new code
  • scripts/run_emf_svg_compare.rb 208 0.1 — 208/208 pass at 0.1px tolerance
  • spec/fidelity_regression_spec.rb — 10/10 pass vs libemf2svg

Add the inverse SVG → EMF translation direction alongside the existing
EMF → SVG renderer. Both directions are now functional and verified.

SVG → EMF:
- Nokogiri-backed SVG parser producing pure value-object domain model
- OCP handler registry: new element type = new handler class
- Handlers for rect, ellipse, circle, line, polyline, polygon, path,
  group (with transforms), text (basic), image (PNG), clip paths,
  defs
- Public API: Emfsvg.from_svg, Emfsvg.from_svg_file, Emfsvg.to_emf
- CLI: emfsvg to-emf INPUT.svg OUTPUT.emf
- Coordinate scaler infrastructure (Identity default, Fixed available)

Lossy SVG matcher (spec/support/svg_matcher.rb):
- Float tolerance, ID canonicalisation, defs hoisting, transform
  flattening
- Proves 208/208 (100%) EMF→SVG semantic equivalence vs libemf2svg
  at 0.1px tolerance (79 byte-identical, 129 cosmetically different)
- Regression spec locks in the fidelity result

Developer tooling:
- scripts/run_emf_svg_compare.rb — fidelity scan vs libemf2svg
- scripts/run_round_trip.rb — SVG→EMF→SVG round-trip scan
- scripts/diff_fixture.rb — element-level diff diagnostics
- scripts/diagnose_round_trip.rb — per-fixture failure reasons

205 specs, 0 failures. Rubocop clean on new code.
@ronaldtse
ronaldtse merged commit 4670e60 into main Jul 26, 2026
0 of 8 checks passed
@ronaldtse
ronaldtse deleted the feat/svg-to-emf branch July 26, 2026 15:18
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