Skip to content

fix(promote): guard promotion to explicit faces + reject variable fonts - #28

Merged
caio-pizzol merged 2 commits into
mainfrom
caio-pizzol/promote-guard
Jun 5, 2026
Merged

fix(promote): guard promotion to explicit faces + reject variable fonts#28
caio-pizzol merged 2 commits into
mainfrom
caio-pizzol/promote-guard

Conversation

@caio-pizzol

Copy link
Copy Markdown
Contributor

Follow-up to #27, addressing the safety caveat: promoting every discovery face of an allow-listed family is fine for Viga (one static Regular face) but unsafe before the next family, which may be variable or multi-weight.

The guard, added before it bites:

  • Allow-list entries now name the exact faces (styleKeys) to promote - never "all faces of this family".
  • selectPromotionFaces (pure, unit-tested) rejects a variable font (it needs a deliberate instancing plan, like gelasio-instances, not direct promotion) and throws on a missing/ambiguous face instead of silently promoting the wrong bytes.

Viga's promoted manifest is byte-identical (still its one static Regular face) - this only hardens the tool. main() is now guarded by import.meta.main so the guard is importable for the test.

Tests prove: Viga regular resolves to one static face; a variable font (Roboto) is rejected; a missing face (Viga bold) and an unknown family throw.

Verified locally: bun test -> 123 pass / 0 fail (incl. 4 guard checks); tsc clean; biome clean; promoted manifest unchanged.

The reviewer flagged that promoting every discovery face of an allow-listed
family is unsafe before the next family (which may be variable or multi-weight).
Add the guard before it bites:

- Allow-list entries now specify the EXACT faces (styleKeys) to take, never
  "all faces of this family".
- selectPromotionFaces (pure, tested) rejects a variable font (it needs an
  instancing plan, like gelasio-instances, not direct promotion) and throws on
  a missing/ambiguous face instead of silently promoting the wrong bytes.

Viga's promoted manifest is byte-identical (still its one static Regular face).
Guarded main() with import.meta.main so the function is importable for the test.
@caio-pizzol
caio-pizzol merged commit 5e62162 into main Jun 5, 2026
1 check passed
@caio-pizzol
caio-pizzol deleted the caio-pizzol/promote-guard branch June 5, 2026 13:26
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.

2 participants