Files
Oleg Isonen 59e0e1111f fix: Publish uploaded fonts used through CSS variables (#6604)
## What changes

Uploaded fonts used through CSS variables now reach the published site.
Previously Builder could render them, but publishing filtered them out
and emitted no `@font-face` rules. This fixes root font variables used
by body and heading tokens with either quote style. The asset manager
also protects those uploaded fonts from being deleted as unused.

Closes #6603

## Implementation

The published bundle follows variables used by `font-family`, parses
their values as font stacks, and handles nested variables without
looping on cycles. Asset usage now uses the same lookup, records each
referring style, and counts every uploaded weight in a family. Replacing
a font used through a variable is blocked because the variable value
cannot be rewritten by the current asset replacement path. Visitors
still download each font file that the page uses; this change makes
those files available rather than falling back to system fonts.

## Checklist

- [x] Reproduce missing font assets in a published project bundle.
- [x] Keep uploaded fonts referenced by root CSS variables and heading
tokens.
- [x] Verify both single and double quotes; exclude unrelated fonts.
- [x] Verify regression tests fail before the publishing fix and pass
afterward.
- [x] Keep fonts referenced through CSS variables out of the
unused-assets list and block deletion.
- [x] Protect every uploaded weight in a used family and block unsafe
font replacement.
- [x] Verify the asset-usage regression tests fail before each fix and
pass afterward.
- [x] Run targeted Builder, project-build, SDK CSS, and CLI prebuild
tests.
- [x] Run Builder, project-build, and CLI typechecks, lint, formatting,
and diff checks.
- [x] Review `docs/`: existing custom-font and CSS-variable guides
already describe the supported behavior; no text change is needed.
- [x] Check fixture inputs and outputs: no fixture contains font
variables, so regeneration is not needed.
- [x] Push the tested changes.
- [x] Monitor required CI checks and fix any failures.

- [x] Simplify font family collection and asset usage without changing
behavior.
- [x] Re-run focused tests, typechecks, and CI after the cleanup.

The cleanup removes a second per-style deduplication map. The collector
now reports each family once per declaration. Production code shrank by
four net lines; the remaining callback and variable map preserve each
style's usage and protect asset deletion and replacement.

- [x] Fix the fixtures diff check after submodule setup moves to current
main.
- [x] Verify the check still catches generated files and edits inside
the submodule.
- [x] Push the CI fix and monitor both PR and push workflows.

## Verification

- Before the publishing fix, both quote variants produced an empty font
asset list in the published bundle. Afterward, both include Inter and
Playfair Display while excluding an unused uploaded font.
- Asset usage tests failed before the follow-up fix for both quote
styles, repeated references, multiple uploaded faces in one family, and
unsafe replacement. They now pass.
- Project-build asset and style utility tests: 95 passed.
- Builder bundle tests: 11 passed.
- CLI prebuild tests: 141 passed.
- Builder, project-build, and CLI typechecks: passed.
- Changed-file lint, formatting, and `git diff --check`: passed.
- Local agent evaluations were not run because they require separate
approval.
- CI: Lint PR, Check submodules, Visual regression, and Main workflow
passed. One unrelated Form E2E test failed on its first run; shard 10
passed on rerun.
- Cleanup checks: 95 project-build tests, 11 Builder bundle tests, and
141 CLI prebuild tests passed. Project-build, Builder, and CLI
typechecks, changed-file lint, formatting, and diff checks passed.
- Cleanup CI: Lint PR, Check submodules, Visual regression, and Main
workflow passed; all ten Builder E2E shards passed.
- CI fix: a local Git reproducer confirmed pointer movement passes while
tracked changes in the parent or submodule fail. YAML parsing and `git
diff --check` passed. The staging push workflow, Linux and Windows
fixture jobs, and all PR checks passed.
2026-10-25 19:46:53 +01:00
..
2023-05-25 19:11:54 +04:00