sttk / linebreak

A library for breaking a given text into lines within a specified width.
MIT License
0 stars 0 forks source link

Support narrow/wide character width of UAX #11 #4

Closed sttk closed 1 year ago

sttk commented 1 year ago

Golang provides the functionality of distinguishing narrow/wide character width according to UAX #11 by golang.org/x/text/width package.

As stated in the specification, it's not enough to distinguish the display width of all characters using this property, but it can serve as a useful guideline, especially for Japanese. I'm a native Japanese speaker and I'm not familiar with languages other than Japanese and English, so for now, I'll use this to determine the display width of characters.

However, this package has private function to determine width of a character(rune), and has mechanism to determine whether a text should be broken into a line based on the result of the function. If I learn of a more suitable way to determine the display width of characters for a specific language or character, I'll adjust the function accordingly.

Ref.