Skip to content

fix: generateBrand: load system fonts only for marks with text (#120) - #121

Merged
FabioHAraujo merged 3 commits into
mainfrom
fix/120-generatebrand-resvg-loads-every-system-font
Oct 15, 2026
Merged

FabioHAraujo merged 3 commits into
mainfrom
fix/120-generatebrand-resvg-loads-every-system-font

Conversation

@FabioHAraujo

@FabioHAraujo FabioHAraujo commented Oct 15, 2026 •

Copy link
Copy Markdown
Collaborator

Closes #120

Regression test (written first)

  • Test reproduces the problem and fails on main
  • Same test passes with the fix

On Windows, the existing test failed on main:

(fail) generateBrand > writes the hashed icon set; inputs, not pixels, decide the hash [13229.13ms]
  ^ this test timed out after 5000ms.

New resvgOptions test (tests/brand.test.ts): before the fix, SyntaxError: Export named 'resvgOptions' not found, 0 pass / 1 fail.

After: 8 pass, 0 fail; writes the hashed icon set takes 0.17 s (was 13.2 s).

Change

@resvg/resvg-js loads every system font on each new Resvg() by default. Measured on Windows 11 for 6 renders of a 512px path-only mark: 2724 ms by default, 30 ms with font.loadSystemFonts: false. generateBrand (and so caBrandPlugin at every build and dev start) renders 6 PNGs per set.

resvgOptions(svg, size) in brand.ts sets fitTo and font.loadSystemFonts: /<text\b/.test(svg), so a mark with text still renders its glyphs. It is not re-exported (the ./vite entry lists its brand exports by name).

Checklist

  • bun run validate passes (validate ok in 169.6s; pre-push gate ✔️)
  • Changeset (bun changeset) if the published package changes
  • Docs updated if behavior or API changed (no API or documented behavior change)

@FabioHAraujo FabioHAraujo changed the title fix: generateBrand: resvg loads every system font per render (12s+ on Windows, brand test times out) fix: generateBrand: load system fonts only for marks with text (#120) Oct 15, 2026
resvg loads every system font on each construction by default: ~450 ms per
render on Windows, ~2.7 s per icon set at every build, and the generateBrand
unit test timed out (13 s against 5 s), failing validate and the pre-push
gate there. The render options now come from resvgOptions(), which turns
system fonts off unless the SVG has <text>.

Closes #120
@FabioHAraujo
FabioHAraujo force-pushed the fix/120-generatebrand-resvg-loads-every-system-font branch from 5551308 to e5fa380 Compare October 15, 2026 03:24
@FabioHAraujo
FabioHAraujo marked this pull request as ready for review October 15, 2026 03:55
@github-actions

Copy link
Copy Markdown
Contributor

Site preview: https://pr-121.codeatlas-ui.pages.dev

@FabioHAraujo
FabioHAraujo merged commit b27c73a into main Oct 15, 2026
14 checks passed
@FabioHAraujo
FabioHAraujo deleted the fix/120-generatebrand-resvg-loads-every-system-font branch October 15, 2026 04:03
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.

generateBrand: resvg loads every system font per render (12s+ on Windows, brand test times out)

1 participant