term.js
term.js copied to clipboard
Additional wide characters
Originally reported as ipython/ipython#8361 - 啊, U+554A, displays wider than a standard character, at least in the monospace font used in my browser. Using it term.js therefore breaks the layout. Adding it to isWide()
fixes things. It's a Han character, and I assume that many of the nearby codepoints will behave similarly. But I don't know how many, or whether there are other fonts that fit them into a standard width.
There is a Python library wcwidth with tables of wide and combining characters; this could be adapted to JS.
@takluyver, JS will be a bit different since it's utf-16 and has to deal with surrogate pairs as well. I've implement wide chars, surrogate pairs, and zero-width combining chars for blessed: https://github.com/chjj/blessed/blob/master/lib/unicode.js
That's, in a way, sort of the inverse of what we want to do here, but the unicode library above will be useful. It's a compilation of a number of helpful unicode modules for node.
here is what you want https://github.com/chjj/term.js/pull/72
I spotted this blog post about the challenges of trying to fit unicode characters to a monospace grid: http://denisbider.blogspot.co.uk/2015/09/when-monospace-fonts-arent-unicode.html
Does my Pull-Request that support CJK languages help ? https://github.com/chjj/term.js/pull/97