Jump to content

Leaderboard


Popular Content

Showing content with the highest reputation on 05/05/24 in all areas

  1. Anders Melander

    How to calculate Unicode text width?

    You are talking about shaping which is not relevant to the problem here. Shaping translates a stream of Unicode code points into glyph IDs and the result 100% depends on the font used to do the shaping. That is the whole point of shaping. FWIW, I've written a shaper so I know a bit about these things... Anyway I just realized that I forgot to explain why it is that... three characters occupy five columns ...even though the font is monospaced. The reason is that the font doesn't contain a mapping for the three Unicode codepoints (U+7F16, U+7801, U+FF1A). So what Windows (or whatever) does, instead of just giving up and display � or □, it searches its fallback font list for a font that 1) supports the Unicode script of the characters (Han in this case) and 2) contains a mapping for the characters (i.e. can map codepoint to glyph id) and then it uses that font to display the glyphs. Since the fallback font isn't monospaced, or at least isn't monospaced with the same character width, you get a different glyph width.
×