Skip to content

fix: load Android auto-size-input fonts from the app's bundled assets (OK-57825) - #116

Merged
huhuanming merged 2 commits into
mainfrom
fix/android-native-font-resolution
Sep 17, 2026
Merged

huhuanming merged 2 commits into
mainfrom
fix/android-native-font-resolution

Conversation

@huhuanming

@huhuanming huhuanming commented Sep 17, 2026

Copy link
Copy Markdown
Contributor

Summary

  • auto-size-input (Android): the input, prefix and suffix now render in the fontFamily the app passes, including fonts bundled in the app's assets/fonts or registered at runtime by expo-font. Before this change, a bundled family such as Roobert-Medium silently fell back to the system font on Android, while iOS rendered it (OK-57825).
  • Only AutoSizeInput.kt changes. Props, JS and iOS are unchanged.
  • Released as 3.0.146.

Root cause

  1. app-monorepo's send amount input passes fontFamily="Roobert-Medium" to AutoSizeInputView (since app-monorepo #12392).
  2. iOS resolves it with UIFont(name:size:). The app registers Roobert-Medium.ttf through UIAppFonts, and the font's PostScript name is Roobert-Medium, so the lookup succeeds.
  3. Android resolved it with Typeface.create(fontFamily, style). That API takes no Context or AssetManager and only looks up system font families. An unknown family does not throw: it returns the default typeface, so the try/catch never ran. The digits and the token symbol rendered in Roboto, or in the OEM system font on many Chinese ROMs.
  4. The app does ship assets/fonts/Roobert-*.ttf, and expo-font registers the same families at runtime. Both live in React Native's ReactFontManager, which this view never queried.

Change

  • makeTypeface() resolves the family with ReactFontManager.getInstance().getTypeface(family, style, context.assets), the lookup React Native Text uses: fonts registered at runtime, then assets/fonts/<family>.ttf|otf, then Typeface.create for system families. pager-view's native headers made the same change in 3.0.141 (fix(android): keep the tab bar under the keyboard and load pager-view header fonts OK-63557 OK-63273 #113).
  • Without a family, the view still uses Typeface.defaultFromStyle(style). fontWeight still maps only "bold" to Typeface.BOLD.
  • Auto-size measurement (the AutoWidthFontFit probe, the binary searches and the side-label widths) calls the same makeTypeface(), so the fitted size is computed from Roobert's glyph widths instead of the fallback font's.

Verification

  • Not built or run on a device or emulator; that was skipped by request.
  • app-monorepo's apps/mobile/android/app/src/main/assets/fonts/Roobert-Medium.ttf is byte-identical to the copy the JS font loader uses, and its PostScript name is Roobert-Medium (checked with fontTools).
  • The new call has the same shape as pager-view's resolveHeaderTypeface and matches React Native 0.86.2's ReactFontManager.getTypeface(String, Int, AssetManager?). The module already depends on react-android.

Other native font lookups checked

Package Android iOS
pager-view native headers ReactFontManager (since 3.0.141) fontWithName:size:
tab-view ReactFontManager RCTFont
native-list createFromAsset("fonts/Roobert-*.ttf") registers its bundled Roobert, then UIFont(name:)
text, text-input React Native text views React Native text views
perp-depth-bar Paint with no typeface: system font CATextLayer with no font: Helvetica
segment-slider Paint with no typeface, fake bold UIFont.systemFont(ofSize:weight: .semibold)

perp-depth-bar and segment-slider never set an app font on either platform. That is not a lookup bug, so they are left for a separate change.

Release

Commit Change
a057c55fc fix(auto-size-input): load Android fonts from the app's bundled assets (OK-57825)
f2a5f65b0 chore: bump packages to 3.0.146

Published from this branch with the latest dist-tag in run 35243178308. The run's registry check passed for all 40 packages, with latest pointing at 3.0.146. The downloaded @onekeyfe/react-native-auto-size-input@3.0.146 tarball's AutoSizeInput.kt and AutoSizeInput.swift are byte-identical to f2a5f65b0.

🤖 Generated with Claude Code

huhuanming and others added 2 commits September 17, 2026 23:52
…s (OK-57825)

makeTypeface() resolved fontFamily with Typeface.create(String, int),
which only looks up system font families. A bundled family such as
Roobert-Medium silently fell back to the default typeface, so the
Android input, prefix and suffix drew in Roboto or the OEM system font
while iOS found the same family through UIAppFonts.

Resolve the typeface through ReactFontManager, the lookup React Native
Text uses: fonts registered at runtime (expo-font), then
assets/fonts/<family>.ttf|otf, and only then Typeface.create. Auto-size
measurement uses the same typeface, so the fitted size follows the real
glyph widths. pager-view's native headers made the same change in
3.0.141.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Bump all 40 publishable packages to 3.0.146 and record the Android
auto-size-input font fix in the changelog.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@sidmorizon

Copy link
Copy Markdown
Contributor

@codex review

@sidmorizon

Copy link
Copy Markdown
Contributor

@codex security review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 17, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-09-17T16:34:05.362164Z f2a5f65 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@sidmorizon

Copy link
Copy Markdown
Contributor

View Devin Review ↗️

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Nice work!

Reviewed commit: f2a5f65b0f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@huhuanming
huhuanming merged commit 849596f into main Sep 17, 2026
4 checks passed
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.

3 participants