Android Fabric text measurement uses Typeface.DEFAULT instead of the system default used for rendering, clipping last glyphs with bold system fonts
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Anfängerfreundlichkeit
- 55/100
- Issue-Typ
- Bug
- Klarheit
- Größtenteils klar
- Aktivitätsstatus
- Ruhig
- Tech-Stack
- android, react-native
- Bereich
- mobile-dev
Rechercherichtung
Start with TextLayoutManager.updateTextPaint() and compare its typeface handling with the ReactTextView rendering path. Reproduce the issue using an Android device with a bold or replacement system font and an auto-width Text component. Done means measurement uses the same default typeface as rendering and the final glyph is no longer clipped.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
Summary
When Android system default font is bolded/replaced (e.g. Xiaomi MiSans Pro Bold / 'full bold' setting), auto-width components are measured with Typeface.DEFAULT while rendering uses the TextView default typeface which inherits the system font configuration. The measured width is therefore too small, and the last glyph can be clipped or missing.
Example: English renders as Englis on Xiaomi with the system-wide bold font enabled.
Environment
- React Native 0.78.3 (Fabric / Bridgeless)
- Android 16 (API 36), Xiaomi HyperOS with system font set to
MiSans Pro Bold - Reproduced on multiple Xiaomi devices
Root cause
TextLayoutManager.updateTextPaint() resets the paint typeface to null (Typeface.DEFAULT) when no explicit font family/weight/style is set, while ReactTextView renders with the TextView default typeface which carries the system bold/replacement config. Different metrics and advances mean measurement is narrower than what is actually drawn.
On device, same 48px text:
| ascent | descent | line height | |
|---|---|---|---|
measurement paint (Typeface.DEFAULT) |
-45 | 3 | 1.0em |
| rendering TextView (system bold) | -50 | 14 | 1.33em |
English (7 glyphs): measured width 53.33dp (only 6 glyphs laid out), drawn width 56.67dp (7 glyphs). The final h is dropped.
Suggested fix
Make the measurement typeface the same source as rendering when no explicit font family/weight/style is set. A local patch that uses the system/default TextView typeface for measurement fixes the issue and was verified on 5 Android devices.
Additional context
This analysis and the local fix were produced with the assistance of an AI coding agent (Codex). Please review independently.
Related
- #49886 (text metrics mismatch / descender clipping)
- Vorherrschende Sprache
- C++
- Sterne
- 127k
- Forks
- 25.3k
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Beitragsleitfaden
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus react/react-native
-
Needs: Author Feedback Needs: Repro
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 92/100
react/react-native#58621 · 1 Kommentar ·
-
Needs: Author Feedback Needs: Repro
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 85/100
react/react-native#58610 · 1 Kommentar ·
-
Needs: Triage :mag:
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 82/100
react/react-native#58565 · 1 Kommentar · 2 Reaktionen ·
-
Needs: Author Feedback Needs: Repro
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 88/100
react/react-native#58555 · 5 Kommentare · 2 Reaktionen ·
-
Needs: Attention Needs: Repro
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 85/100
react/react-native#58526 · 2 Kommentare ·
Alle Issues in react/react-native
Ähnliche Issues
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 70/100
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 65/100
duckdb/duckdb-wasm#2258 ·
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 75/100
objectionary/eo-graphs#75 ·
-
Coarray integration tests carry no LABELS, so run_tests.py silently skips them under every backend Offencoarray
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 70/100
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 75/100
FISCO-BCOS/FISCO-BCOS#5642 ·