Skip to content

swiftdraw-diff: render text with the resvg CLI when PNGs are given too - #225

Merged
swhitty merged 1 commit into
mainfrom
claude/diff-text-cli-fallback
Nov 17, 2026
Merged

swhitty merged 1 commit into
mainfrom
claude/diff-text-cli-fallback

Conversation

@swhitty

@swhitty swhitty commented Nov 17, 2026

Copy link
Copy Markdown
Owner

Follow-up to #209.

resvg's test-suite PNGs were drawn with the suite's own Noto fonts. When --resvg-png was used, every file containing <text> was compared against glyphs that SwiftDraw, which uses Times, Helvetica and Courier, can never match.

Changes

  • Text uses the CLI. With both --resvg and --resvg-png, any file containing <text> is rendered by the resvg CLI, with the fallback-font flags and --font-size 16. Every other file keeps its PNG when the PNG is usable.
  • PNGs only. With --resvg-png alone, behaviour is unchanged. The summary now says how many text files were compared against pre-rendered PNGs, which may use other fonts, and suggests adding --resvg.
  • Which reference each file used. scores.json and compare.json gain resvgSource (png or cli) for each file. The summary counts the text files the CLI rendered. When PNGs were given, it marks CLI-rendered files: (resvg CLI) in report mode, […, resvg CLI] in compare. The references line reads resvg PNGs (…), resvg 0.50.0 for text and unusable PNGs.
  • Docs. The --resvg-png help and AGENTS.md's resvg-suite paragraph are updated.
  • Tests. The PNG-or-CLI choice is now Options.prefersResvgPNG, with unit tests.

Verification

  • swift test --package-path Tools/swiftdraw-diff: 27 tests in 6 suites pass.
  • compare --base origin/main --resvg Samples.bundle: 181 of 181 unchanged, no regressions.
  • Full resvg suite at main (7a54105) with --resvg --resvg-png sibling --scale 2 (1,801 files):
pass pass, WebKit differs pass, resvg differs unclear SwiftDraw bug all pass verdicts
before 1054 126 197 84 336 1377
after 1159 299 92 84 163 1550

All 430 text files now use the CLI; the other 1,342 files keep their PNG, and 28 files without a usable PNG fall back to the CLI as before. No file's verdict got worse, and no non-text file's score changed at all. The pass gain is in text files only:

files pass before pass after
text outside text/ 44 12 36
text inside text/ 386 125 274

🤖 Generated with Claude Code

resvg's test-suite PNGs were drawn with the suite's Noto fonts, so text in
them never matches SwiftDraw's fallback fonts. With --resvg and --resvg-png,
files containing <text> now always use the resvg CLI (fallback fonts,
--font-size 16); other files keep their PNG when usable. With --resvg-png
alone, the summary says how many text files are compared against PNGs with
other fonts.

Each file records its resvg source (resvgSource: png|cli) in scores.json
and compare.json; the summary counts text files rendered by the CLI and
marks CLI-rendered files when PNGs were given.
@swhitty
swhitty force-pushed the claude/diff-text-cli-fallback branch from a337862 to 953915d Compare November 17, 2026 20:22
@swhitty
swhitty merged commit 5efe2b7 into main Nov 17, 2026
17 of 18 checks passed
@codecov

codecov Bot commented Nov 17, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.23%. Comparing base (7a54105) to head (953915d).
⚠️ Report is 7 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #225   +/-   ##
=======================================
  Coverage   95.23%   95.23%           
=======================================
  Files         296      296           
  Lines       31260    31260           
=======================================
+ Hits        29771    29772    +1     
+ Misses       1489     1488    -1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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