suragch / mongol

Mongolian vertical script widgets for Flutter apps
https://pub.dev/packages/mongol
BSD 3-Clause "New" or "Revised" License
71 stars 15 forks source link

The Arabic numerals cannot be wrapped correctly. #54

Open iceXice opened 2 weeks ago

iceXice commented 2 weeks ago

ver 8.0.0

截屏2024-10-14 11 28 12

iceXice commented 2 weeks ago

截屏2024-10-14 14 34 03

const text2 = TextSpan( children: [ TextSpan(text: '1234567890'), TextSpan(text: '👨‍👩‍👧'), TextSpan(text: '👋🏿'), TextSpan(text: '🇭🇺'), TextSpan(text: '一二三四五六七八九十'), TextSpan( text: '\uD83D\uDE03\uD83D\uDE0A\uD83D\uDE1C\uD83D\uDE01\uD83D\uDE2C\uD83D\uDE2E\uD83D\uDC34\uD83D\uDC02\uD83D\uDC2B\uD83D\uDC11\uD83D\uDC10'), TextSpan(text: '①②③㉑㊿〖汉字〗한국어モンゴル語English? ︽ᠮᠣᠩᠭᠣᠯ︖︾'), ], );

suragch commented 2 weeks ago

This is a problem with the line-breaking. Flutter doesn't give access to a good line-breaker so the current solution in this package just breaks lines on single emojis, CJK characters, newlines, and spaces. The implementation is here:

https://github.com/suragch/mongol/blob/master/lib/src/base/mongol_paragraph.dart#L1108

To solve this, we would need a more sophisticated algorithm that breaks long words (both English and Mongolian) and numbers across lines. Ideally it would prefer breaking at certain characters such as /, -, etc.

See also: