Repository navigation
fix(ui): draw the system font until the brand faces register (YPE-5637) - #169
Conversation
`Text` and `Button.Text` asked for the `Inter_*` faces that expo-font registers at runtime, after first paint. Native falls back to the system font for an unknown family, and Fabric's text measure cache compares attributed strings layout-wise, so a color-only re-render (a theme flip) kept the system-font measurement while the draw path picked up the wider, now-registered Inter. Button labels ellipsized and paragraphs lost their last line. Draw the system font on purpose via `sansFace(family, weight, ready)` until `useBrandFonts` reports the bundled sans faces registered, then switch `fontFamily`, a layout attribute, so native re-measures. `YouVersionProvider` publishes the flag through `BrandFontsContext`. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
|
Tracking in YPE-5637. Assigned to Dustin. posted by Cursor on behalf of Dustin |
Anti-slop forbids unknown, typeof, and an anonymous return type on the helper. Co-authored-by: Cursor <cursoragent@cursor.com>
The token ADR still told primitives never to use fontWeight. That would put Inter on the first frame again and bring the clip back. Co-authored-by: Cursor <cursoragent@cursor.com>
cameronapak
left a comment
There was a problem hiding this comment.
Review
Jira ticket: YPE-5637
Summary
- Standards must-fix: 0
- Spec must-fix: 0
- Worst: none — system font until Inter registers, then family swap forces remeasure
Would approve on criteria. UI PR: no GitHub APPROVE — Cam looks at the repro screenshots (and the fix pass if you re-check on device).
For Agents: pin / CI
- HEAD:
d5578d15b7ca48ea49882d022940449bbc87847f - Fix:
sansFace+BrandFontsContext/useBrandFontsReady; Text + Button.Text consume; serif load stays non-blocking - Tests:
holdSansRegistrationseam; Text/Button transition asserts - Docs: AGENTS gotcha + ADR 0021 amend; patch changeset
- Out of scope (called out): Android device pass, Inter config-plugin bundling
- CI: Lint/Typecheck/Build/Test/Locale parity/Locale JSON guard/Greptile Review pass
- Greptile: 5/5
- Event: COMMENT only (UI)
By Code Reviewer bot, sent on behalf of Cam.
cameronapak
left a comment
There was a problem hiding this comment.
Review
Summary
- Standards must-fix: 0 (prior pass)
- Spec must-fix: 0 (prior pass)
- Direction (Cam): Prefer awaiting Inter in the provider and deleting the ready/system-font path — do not keep two permanent font paths.
For Agents
Prior COMMENT on same HEAD: Spec 0 / Standards 0; UI → no APPROVE.
Cam + Simplifier joint: approach A — hold children until sans Font.loadAsync, then always Inter; delete BrandFontsContext / sansFace(ready=false) / hold-sans-registration.
Not C (ship dual-path). Native preload (B) later only if first-paint hold is unacceptable.
Event: COMMENT with Dustin instructions.
By Code Reviewer bot, sent on behalf of Cam.
|
Hi Dustin! I am an AI agent (even though this looks like Cam). Cam sent me to share research for this PR. I read the React Native source, the expo-font source, and the Expo docs. Each claim below links to its primary source. Root cause, checked against the React Native source The text measure cache lives in The bug is the cache key. The key stores the The current fix removes the split in two steps. The readiness shape matches the expo-font source
Related bugs in React Native
One detail from #58176 helps this PR. A bare family name plus a weight resolves through a different code path, and that path stays correct. So do not set a PostScript How the ecosystem normally loads custom fonts
All three patterns are standard. Pattern (b) at provider scope gives one font path and no font flash. The first paint of the SDK content then waits for the local sans load. Pattern (c) paints immediately, and it shows a brief system-font flash plus one reflow. The sources above support either direction. Thanks for the clear problem statement and the repro. I hope these sources help the review talk. References
|
|
Question I'm wrestling with... Is this the best way to solve this now? AI Meat Proxy Response ✨
|
Drop the system-font swap so native text always draws Inter after the provider opens. Co-authored-by: Cursor <cursoragent@cursor.com>
Card titles read that slot for color; folding Inter into the variant layer restores it. Co-authored-by: Cursor <cursoragent@cursor.com>
cameronapak
left a comment
There was a problem hiding this comment.
Looks a lot simpler. If this works as you think, I approve!
Problem
After any re-render that only changes text color (a theme flip is the easiest repro),
Button.Textlabels ellipsize ("Share" → "Sh…") and multi-lineTextdrops its last line. Headings also render regular weight on the first frame and turn bold on the next re-render.Repro (confirmed on
main)Main's example tabs do not mount these primitives (Bible / VOTD / Card are webviews). Put native
TextandButton.Texton a throwaway screen — Share / Read chapter in a card footer is enough — then:Features → Toggle Appearance).Labels clip. Flipping back to Light does not re-measure; the ellipsis stays.
Captured on iPhone 17 Pro simulator, 2026-09-04:
1. Light, cold start — labels intact
2. Dark, after ⌘⇧A — Share → Sh…, Read chapter → Read chap…
3. Light again — ellipsis persists
Root cause
TextandButton.TextsetfontFamilyto theInter_*aliases that expo-font registers at runtime, after first paint. iOS resolves an unknown family to the system font. Fabric's text measure cache (TextMeasureCache.h,areTextAttributesEquivalentLayoutWise) ignores color, so a color-only re-render reuses the system-font measurement while the draw path picks up the now-registered, wider Inter.Fix
sansFace(family, weight, ready)intheme/fonts.tsreturns{ fontWeight }(system font, on purpose) until the faces register, then{ fontFamily: fontMapKey(...) }. ChangingfontFamilyis a layout attribute, so native re-measures.useBrandFontsnow returns a "sans registered" boolean;YouVersionProviderpublishes it throughBrandFontsContext/useBrandFontsReady().TextandButton.Textconsume it. No public API change.sansFacerather than a hand-writtenfontFamily/fontWeight.@youversion/platform-react-native-expo-ui.Verification
pnpm typecheck,pnpm test,pnpm lintgreen.mainwith the screenshots above.Not in this PR
🤖 Generated with Claude Code
Greptile Summary
The PR prevents native text from rendering before bundled Inter faces register, ensuring text measurement and drawing use the same font.
YouVersionProviderchildren on bundled sans-font readiness while loading serif fonts in the background.sansFaceforTextandButton.Text.Confidence Score: 5/5
The PR appears safe to merge.
No blocking failure remains.
Important Files Changed
sansFacehelper for selecting registered Inter aliases withoutfontWeight.sansFace.Sequence Diagram
sequenceDiagram participant App as Consumer app participant Provider as YouVersionProvider participant Fonts as expo-font participant UI as Native UI primitives Provider->>Fonts: Check bundled Inter faces alt Faces already registered Provider->>UI: Mount children else Faces not registered Provider->>Fonts: loadAsync(bundledSans) Fonts-->>Provider: Registration completes Provider->>UI: Mount children end UI->>UI: Resolve mapped face with sansFaceReviews (5): Last reviewed commit: "fix(ui): keep Text caller style in the s..." | Re-trigger Greptile
Context used (3)