react-native-skia icon indicating copy to clipboard operation
react-native-skia copied to clipboard

[Feature Request] Support precise glyph bounds measurement with font fallback

Open ReedYu opened this issue 2 months ago • 0 comments

Description

Need: Measure text with font fallback support AND get precise glyph bounds (not font metrics). Current limitations: ·Font.measureText(): Precise bounds ✅ but no font fallback ❌ ·Paragraph.getRectsForRange(): Font fallback ✅ but uses fixed font metrics ❌

// "Hello" (no descenders) vs "Typography" (has y, p, g descenders)

Font.measureText("Hello"):       height ≈ 17 (tight to glyphs)
Font.measureText("Typography"):  height ≈ 24 (includes descenders)

Paragraph.getRectsForRange("Hello"):      height ≈ 24 (reserves descender space)
Paragraph.getRectsForRange("Typography"): height ≈ 24 (same as "Hello")

Use case: Single-line multilingual text measurement (e.g., "Hello你好") for UI layouts where precision matters. Need automatic font fallback from English to Chinese fonts, but also need bounds that adapt to actual glyphs, not fixed font metrics. Thanks! 🙏

ReedYu avatar Oct 29 '25 10:10 ReedYu