tangrams / tangram

WebGL map rendering engine for creative cartography
https://tangram.city
MIT License
2.22k stars 290 forks source link

When the text is Chinese, the text_wrap parameter does not work. #446

Open ligai322 opened 8 years ago

ligai322 commented 8 years ago

for example: I come from Beijing. But This sentence write in Chinese, like '我来自北京'. I have already submitted the question in tangram-es.Text line breaks The tangram has the same problem.

bcamper commented 7 years ago

Would be great to get this fixed for next release.

dmvaldman commented 7 years ago

This is a little more complicated on the JS side because we can't lean on another library to tell us if we can break on a character in a word.

In English, for example, a long word that overflows the word-wrap value would need to break on a random character (if we don't do something clever, such as hyphenate, which is probably only more complicated). This would be bad, but for Chinese, breaking on most characters are fine (as far as I understand).

Leaving this link from the ES PR for reference here: https://en.wikipedia.org/wiki/Line_breaking_rules_in_East_Asian_languages

dmvaldman commented 7 years ago

Though apparently there is a TC39 proposal to bring this to JS https://github.com/tc39/proposal-intl-segmenter