-
Notifications
You must be signed in to change notification settings - Fork 6
Open
Description
Follow-up to #149 (task 3).
Problem
After removing hardcoded spaces from i18n strings, CJK–Latin text has zero spacing between scripts (e.g. 關於TAT, Project Tattoo (TAT)是國立臺北科技大學). The correct inter-script gap is ~1/4 em per the W3C CLREQ spec.
Flutter has no native support for this — flutter/flutter#94531 has been open since 2021 with no progress.
Approaches
A. AutoSpacingText widget (TextSpan splitting)
Split the string at CJK–Latin boundaries, build a Text.rich() with WidgetSpan gaps for precise ~1/4 em spacing.
- Precise spacing control
- Every
Text()displaying CJK-mixed content must be swapped toAutoSpacingText() - Doesn't work in non-widget contexts (SnackBar, InputDecoration, AlertDialog title)
- High maintenance: must forward all
Textparameters
B. String extension
Insert a thin Unicode space (U+2009 or U+200A) at CJK–Latin boundaries via a String extension like .autoSpaced.
- Works everywhere — any widget or context that takes a
String - Easy incremental adoption, low maintenance
- Spacing width depends on font (not exactly 1/4 em, but close)
- Can be removed cleanly if Flutter adds native support
C. i18n wrapper
Override slang's string access to auto-apply spacing to all translated strings.
- Zero call-site changes for i18n strings
- Doesn't cover dynamic content from NTUT services
- Can layer on top of B
References
- W3C CLREQ — Mixed text in horizontal writing
- CSS
text-autospace - Unicode UTR #59
- flutter/flutter#94531
- pangu.dart — reference for CJK–Latin boundary detection regexes
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels