fix(promote): guard promotion to explicit faces + reject variable fonts - #28
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
selectPromotionFaces(pure, unit-tested) rejects a variable font (it needs a deliberate instancing plan, likegelasio-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 byimport.meta.mainso 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.