Repository navigation
Commit c1401a1
Log unrecognized font family on Android (#58804)
Summary:
On Android, a `fontFamily` that can't be resolved silently falls back to the default system font. iOS logs `Unrecognized font family '<name>'` in the same case (`RCTFont.mm`). This adds the same log on Android, only when `Typeface.create` falls back to the default typeface, so valid system families like `monospace` don't log. Like `RCTLogInfo` on iOS, it only runs in debug builds.
Fixes #58750
Replaces #58751, which was closed by accident when its fork got detached.
## Changelog:
[ANDROID] [ADDED] - Log unrecognized font families, matching iOS
Pull Request resolved: #58804
Test Plan:
Ran this branch's `ReactFontManager.kt` in a test app on an API 35 emulator and checked logcat. Debug build:
- `'FontFamilyThatDoesNotExist'` logs `Unrecognized font family 'FontFamilyThatDoesNotExist'` (once per style)
- `'monospace'`, `'serif'`, `'sans-serif'`, `'sans-serif-medium'`, `'cursive'`, fonts in `assets/fonts/` and fonts added with `addCustomFont` log nothing
- Every font family name declared on the device (34 names, all 4 styles) logs nothing
Release build: nothing is logged, including for `'FontFamilyThatDoesNotExist'`.
Repro: [RNTesterPlayground.js](https://github.com/mosab-nasrallah/react-native/blob/repro-android-unknown-font-family/packages/rn-tester/js/examples/Playground/RNTesterPlayground.js)
Reviewed By: javache
Differential Revision: D122984557
Pulled By: fabriziocucci
fbshipit-source-id: 692295588db632d80673430b27e5a8c50cd247c01 parent 148a6e0 commit c1401a1
1 file changed
Lines changed: 14 additions & 1 deletion
File tree
- packages/react-native/ReactAndroid/src/main/java/com/facebook/react/common/assets
Lines changed: 14 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| 14 | + | |
14 | 15 | | |
15 | 16 | | |
16 | 17 | | |
| 18 | + | |
17 | 19 | | |
18 | 20 | | |
19 | 21 | | |
| |||
162 | 164 | | |
163 | 165 | | |
164 | 166 | | |
| 167 | + | |
| 168 | + | |
165 | 169 | | |
166 | 170 | | |
167 | 171 | | |
| |||
184 | 188 | | |
185 | 189 | | |
186 | 190 | | |
187 | | - | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
188 | 201 | | |
189 | 202 | | |
190 | 203 | | |
| |||
0 commit comments