Skip to content

Add CJK–Latin inter-script spacing at the rendering layer #178

@rileychh

Description

@rileychh

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 to AutoSpacingText()
  • Doesn't work in non-widget contexts (SnackBar, InputDecoration, AlertDialog title)
  • High maintenance: must forward all Text parameters

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions