Skip to content

feat(fallbacks): carry glyphExceptions on the resolved fallback#44

Merged
caio-pizzol merged 1 commit into
mainfrom
caio-pizzol/fallback-glyph-exceptions
Jun 6, 2026
Merged

feat(fallbacks): carry glyphExceptions on the resolved fallback#44
caio-pizzol merged 1 commit into
mainfrom
caio-pizzol/fallback-glyph-exceptions

Conversation

@caio-pizzol
Copy link
Copy Markdown
Contributor

The renderable fallback already says which family, the verdict, line-break safety, and face coverage. Add the row's glyph exceptions to it too, so a consumer (SuperDoc's report) can surface a precise "this face reflows on U+0060" without re-deriving from SUBSTITUTION_EVIDENCE.

One optional field on FontFallback, projected by the existing helpers - no new API, no new mental model:

  • getRenderableFallback / getFallbackDecision (family): all of the row's exceptions, with the top-level verdict.
  • getRenderableFallbackForFace / getFallbackDecisionForFace (face): only that face's exceptions, with the per-face verdict - Cambria Regular carries none, Bold Italic carries its grave-accent exception.

Optional + additive (omitted when a fallback has none, e.g. Calibri), so it's a minor 0.4.0. No data change. This keeps everything in @docfonts/fallbacks - the question "the fallback I'm about to render, how faithful is it?" belongs on FontFallback; a separate evidence package would add two installs and a second mental model for no second consumer.

After this ships, SuperDoc #3672 can drop its local verdict/exception projection and copy these fields straight off getRenderableFallback/getRenderableFallbackForFace.

Verified: typecheck/lint clean; bun test 24 pass (3 new: family=all, face=filtered, none-omitted); built dist loads in Node and projects correctly (Cambria family [boldItalic], Regular undefined, Bold Italic [boldItalic]).

The renderable fallback already says which family / verdict / line-break-safety
/ faces; add the row's glyph exceptions so a consumer can surface a precise
'this face reflows on U+0060' without re-deriving from SUBSTITUTION_EVIDENCE.
Projected by the existing helpers, no new API:

- getRenderableFallback / getFallbackDecision (family): all of the row's
  exceptions, with the top-level verdict.
- getRenderableFallbackForFace / getFallbackDecisionForFace (face): only that
  face's exceptions, with the per-face verdict - so Cambria Regular carries none
  while Bold Italic carries its grave-accent exception.

Optional + additive (omitted when none, e.g. Calibri). The field is a readonly
GlyphException[] and a FRESH array each call (the family path copies, filter
already copies), so a consumer mutating it can never corrupt the shared evidence
row for a later lookup. No data change.
@caio-pizzol caio-pizzol force-pushed the caio-pizzol/fallback-glyph-exceptions branch from fd60bdc to 2c11227 Compare June 6, 2026 01:49
@caio-pizzol caio-pizzol merged commit 3e62ce6 into main Jun 6, 2026
1 check passed
@caio-pizzol caio-pizzol deleted the caio-pizzol/fallback-glyph-exceptions branch June 6, 2026 01:50
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