Android Fabric text measurement uses Typeface.DEFAULT instead of the system default used for rendering, clipping last glyphs with bold system fonts
Chưa có ai nhận issue này.
- Ngôn ngữ chính
- C++
- Star
- 127k
- Fork
- 25.3k
- Merge trung bình
- 1 ngày 23 giờ
- Pull request đã merge (30 ngày)
- 4
Mô tả
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)
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Hướng nghiên cứu
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.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- android, react-native
- Lĩnh vực
- mobile-dev
- Loại issue
- Lỗi
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức độ hoạt động
- Ít trao đổi
- Độ rõ ràng
- Khá rõ ràng
- Mức phù hợp với người mới
- 55/100