Skip to content

fix: switch to XML font resources so Nunito/Lora render on first frame - #59

Merged
mapgie merged 1 commit into
mainfrom
claude/chore-dash-font-consistency-7u8bb4
Jun 21, 2026
Merged

fix: switch to XML font resources so Nunito/Lora render on first frame#59
mapgie merged 1 commit into
mainfrom
claude/chore-dash-font-consistency-7u8bb4

Conversation

@mapgie

@mapgie mapgie commented Jun 21, 2026

Copy link
Copy Markdown
Owner

Root cause

The programmatic GoogleFont.Provider + Font(googleFont = ..., fontProvider = ...) approach from ui-text-google-fonts loads fonts asynchronously inside the Compose runtime. If GMS doesn't serve the font before the first composition completes (which is common — there is no guaranteed delivery window), the system fallback (Roboto) is used permanently with no visible error. This is exactly what v0.15 showed: every headlineLarge title that should have been Lora 32sp SemiBold was rendering as Roboto.

Fix

Replace the programmatic approach with per-weight XML font descriptors in res/font/:

nunito_regular.xml   → name=Nunito&weight=400
nunito_medium.xml    → name=Nunito&weight=500
nunito_semibold.xml  → name=Nunito&weight=600
nunito_bold.xml      → name=Nunito&weight=700
lora_medium.xml      → name=Lora&weight=500
lora_semibold.xml    → name=Lora&weight=600

Type.kt now references these as Font(R.font.nunito_regular, FontWeight.Normal) etc., which routes font loading through ResourcesCompat instead of the Compose runtime. ResourcesCompat is pre-warmed by the system launcher via the new preloaded_fonts manifest declaration, so by the time any Compose text renders the fonts are already in the process cache.

Changes

  • app/src/main/res/font/ — 6 new XML font descriptors (Nunito 400/500/600/700, Lora 500/600)
  • app/src/main/res/values/preloaded_fonts.xml — array listing all 6 fonts for launcher pre-warming
  • app/src/main/AndroidManifest.xml<meta-data android:name="preloaded_fonts"> inside <application>
  • app/src/main/java/com/mapgie/dash/ui/theme/Type.kt — removed GoogleFont.Provider setup; Nunito and Lora FontFamily now use Font(R.font.xxx) references
  • app/build.gradle.kts — removed implementation(libs.androidx.ui.text.google.fonts)
  • gradle/libs.versions.toml — removed androidx-ui-text-google-fonts entry
  • app/.../licenses/LicensesScreen.kt — removed "AndroidX Compose UI Text (Google Fonts)" license entry
  • changelog/unreleased/font-consistency.json — patch fragment

Test plan

  • Build and install on a real device (GMS present)
  • Open a chore sheet: title should appear in Lora SemiBold (serif) at 32sp immediately — no flash of Roboto before it arrives
  • Body text and metadata should use Nunito (rounded terminals, uniform stroke vs Roboto)
  • Cold-start test: force-stop the app, relaunch, open sheet — Lora still present on first frame
  • Verify Open Source Licences screen no longer lists "AndroidX Compose UI Text (Google Fonts)"

🤖 Generated with Claude Code


Generated by Claude Code

The programmatic GoogleFont.Provider approach (ui-text-google-fonts) loads
fonts asynchronously inside the Compose runtime and can silently fall back
to the system font when GMS doesn't serve the font in time.

Switching to per-weight XML font descriptors (res/font/*.xml) routes loading
through ResourcesCompat, which the launcher pre-warms via the preloaded_fonts
manifest declaration. Fonts are in the process cache before any Compose
composition runs, so Nunito and Lora appear on the very first frame.

Removes the ui-text-google-fonts dependency entirely; font_certs.xml is kept
because the XML descriptors still reference com_google_android_gms_fonts_certs.
@mapgie
mapgie marked this pull request as ready for review June 21, 2026 15:39
@mapgie
mapgie merged commit e42ac2b into main Jun 21, 2026
5 checks passed
@mapgie
mapgie deleted the claude/chore-dash-font-consistency-7u8bb4 branch June 21, 2026 15:39
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.

1 participant