enthought / enable

Enable: low-level drawing and interaction
Other
91 stars 45 forks source link

Provide better support for mixed writing systems #762

Open jwiggins opened 3 years ago

jwiggins commented 3 years ago

This is mainly a problem of the AGG backends. Quartz and QPainter backends already have the correct behavior.

Basically, user code should be able to call show_text on the following string: "Kiva Graphics一番😎" and have it render correctly even if the currently selected font only supports Latin characters.

To get to this point, we need to do a few things:

This is roughly what Qt does, based on a quick skim of the code: https://code.qt.io/cgit/qt/qtbase.git/

jwiggins commented 3 years ago

Lovely: https://raphlinus.github.io/rust/skribo/text/2019/04/04/font-fallback.html

jwiggins commented 3 years ago

Copying from #767 so it's easier to find:

Having played with [mapping of "Han" to a CJK language] a bit more, we should only use [the locale-based guess] when it's not otherwise clear from the context. For instance if a string already contains Hiragana or Katakana, then Han should be mapped to "Japanese". If Hangul is encountered, Han maps to "Korean". Only if the Han is mixed with some non-CJK language should we fall back to this locale-based guess.

jwiggins commented 2 years ago

Consider libgrapheme or utf8proc for classifying graphemes in a string.