Skip to content

Odd Handling of Unicode (Part 2) #553

Closed

Description

@ElvenSpellmaker

It was great to see #285 being fixed recently but this hasn't fixed other issues with Unicode handling, such as used in the Tamil script or with the Lenny Face ( ͡° ͜ʖ ͡°) as can be seen below:
lennyface
When passing this through a programme to dump the runes I get:

U+0028 - LEFT PARENTHESIS
U+0020 - SPACE
U+0361 - COMBINING DOUBLE INVERTED BREVE
U+00B0 - DEGREE SIGN
U+0020 - SPACE
U+035C - COMBINING DOUBLE BREVE BELOW
U+0296 - LATIN LETTER INVERTED GLOTTAL STOP
U+0020 - SPACE
U+0361 - COMBINING DOUBLE INVERTED BREVE
U+00B0 - DEGREE SIGN
U+0029 - RIGHT PARENTHESIS

As said earlier there seems to be problems with the handling of Tamil combinations, some of them producing wider characters than two wide (up to about 5 wide!)

For examples, let's look at the character for 'year': ௵
tamilyear
As can be seen above:

  1. It renders fine on its own, being 3 wide. If you try to select it it becomes 1 wide again.
  2. It renders clipped with following characters (because the terminal thinks it's only 1 wide).
  3. It renders 1 wide when entering it into the terminal (editor or bash etc.).

Similarly with the 'character' ணௌ, which is a combination of two symbols ண் and ஔ:

ணௌ:

U+0BA3 - TAMIL LETTER NNA
U+0BCC - TAMIL VOWEL SIGN AU
  1. Displays fine on its own.
  2. Clipped to 2 width when in an editor
  3. Renders correctly when there is text next to it and selection ruins it (unlike the year sign)

tamiltest1

ண்:

U+0BA3 - TAMIL LETTER NNA
U+0BCD - TAMIL SIGN VIRAMA
  1. Displays 1 width on its own.
  2. Same as 1.
  3. Same as 1.

ஔ:

U+0B94 - TAMIL LETTER AU
  1. Displays fine on its own.
  2. Clipped to 1 width in an editor/shell
  3. Renders correctly when text is next to it and selection ruins it

ண:

U+0BA3 - TAMIL LETTER NNA
  1. Shows as 2 wide.
  2. Gets clipped to 1 wide.
  3. Gets clipped to 1 wide.

Interesting notes:

  1. In bash ண் gets deleted on backspace, whereas in irssi just the VIRAMA sign gets removed leaving the plain NNA.
  2. Pressing up in bash for command history will show characters in one of two fashions:
    1. The width they are meant to be (except ண்) forcing any text after the character to appear clipped (even if normally the text wouldn't be clipped)
    2. The width they are meant to be, overwriting anything 'under' it (ணௌ)

An example of behaviour 2.) i.) is shown below:
tamiltest2
As you can see, the third j is clipped, when normally it'd not clip.

These aren't exhaustive examples and only focus on a few characters, but hopefully the issue is demonstrated well enough here.

See Tamil Script for more information about Tamil glyphs and more examples of different glyphs and combinations.

Activity

  1. mintty commented on May 22, 2016

    @mintty
    Owner

    I am not really familiar with Indic scripts but I've read they don't fit well into the cell-based terminal concept. I don't think the Unicode standard provides any hint on which or when Indic characters should be supposed to be more than 1 cell wide, and whether they are 2 cells, 3 cells, or 1½ cell.
    Neither am I aware of any working terminal that supports Indic. There was supposed to be an Indic xterm clone on some Indic X Windows site or so, but I wasn't able to download and compile and run it.
    If you're interested in getting Indic support in mintty, some information reference will be useful:

    • Description or standards of Indic character handling, cell width, ligatures etc.
    • Terminals with Indic support.
    • A selection of Indic monospace fonts. Actually, the weird behaviour you described might be attributed to the Windows font fallback mechanism if the Indic characters are actually not included in the selected font.
  2. mintty commented on May 31, 2016

    @mintty
    Owner

    I have experimentally made Tamil characters wide. This works well, display looks fine.
    The question is, by what condition (preferably derived from a standard or publicly available description) should a character be considered wide that is not wide by the locale mechanism?
    (Furthermore, most screen-oriented applications would still fail to handle them properly because they typically base on the wcwidth function of the locale mechanism which would then be inconsistent; for my own editor (MinEd), that would be a good solution, actually.)
    Any further suggestions please?

  3. ElvenSpellmaker commented on Jun 1, 2016

    @ElvenSpellmaker
    Author

    You are correct about the East Asian scripts, Unicode still hasn't got around to defining them properly 😞

    For example, in the Unicode Database files there is a file describing widths for the 'EastAsian' characters, found here: EastAsianWidth

    For example ணௌ is shown as:

    0BA3..0BA4;N     # Lo     [2] TAMIL LETTER NNA..TAMIL LETTER TA
    0BCA..0BCC;N     # Mc     [3] TAMIL VOWEL SIGN O..TAMIL VOWEL SIGN AU
    

    Both are classed as N for Narrow... 😞

    I'm sure you will have seen this before where the types are described a bit: http://unicode.org/reports/tr11/

    And there's a blog post here about discussion around widths and how we're still not prescribed proper widths in 2015... http://denisbider.blogspot.co.uk/2015/09/when-monospace-fonts-arent-unicode.html

    Oh well it seems this is unsolvable without having a list of exceptions (which again could be wrong with different fonts and different regions seemingly)...


    However, even if the second part of this issue is unsolvable (it will be it seems), then the Lenny Face part still stands: ( ͡° ͜ʖ ͡°) should show correctly in the terminal surely?

    In this case it just seems that the combining breves just aren't combining in mintty (same behaviour in cmder and console2, but other UNIX terminals get this right just fine (such as xfce-terminal)).

  4. mintty commented on Jun 1, 2016

    @mintty
    Owner

    So you don't have a list of wide Indic characters either. Are they perhaps simply all wide?
    But it looks that some have very "odd" widths indeed (as also mentioned in the blog you referenced), like 1½, 2½, or 3 cells? If you have an idea how to handle that, let's discuss. Otherwise, if mintty would approximate the rendering width by the assumption of 2-cell Indic width, would the result be good enough that such an approach is worth the effort?

    About the Lenny Face, it also depends on the font; it looks fine with Consolas. To be checked.

  5. mintty commented on Jun 9, 2016

    @mintty
    Owner

    I have uploaded an experimental option WideIndic=true to support wide display of "wide" Indic characters.
    Please check whether that is any useful; see the notes in the manual page.

  6. mintty commented on Jun 22, 2016

    @mintty
    Owner

    About the Lenny Face again, actually the source you quoted is not correct; the combining characters apparently precede the characters they are intended to combine with, which is wrong. I wonder why my browser renders it so it looks as intended (that's why I only noticed this error now)
    – which is in turn wrong!
    The proper sequence would be (°͡ʖ͜°͡) and that renders correctly in mintty although the actual display isn't always nice, also depending on the font.

  7. ElvenSpellmaker commented on Jun 22, 2016

    @ElvenSpellmaker
    Author

    I believe you're combining this the wrong way around in mintty, as the above looks wrong in every browser, but the way I posted looks fine in a browser and other terminals.
    c.f. ( ͡° ͜ʖ ͡°) vs (°͡ʖ͜°͡).

    I'm using Consolas in mintty and Github defaults to it too.

    If you type "Lenny Face" into google, every time I copy any for example, it's the way I posted above which mintty doesn't handle.


    Also thanks, I'll check out the WideIndic soon and see what it's like. =)

  8. mintty commented on Jun 24, 2016

    @mintty
    Owner

    The sequence

    U+0020 - SPACE
    U+0361 - COMBINING DOUBLE INVERTED BREVE
    U+00B0 - DEGREE SIGN
    

    means "place the combining character on the space character, then append the degree sign".
    This is common Unicode semantics. If it renders as if the combining character would appear over the degree sign, it can have two causes; in a proportional font, the space may be sufficiently thin so that a combining mark on it extends well over the next character; or otherwise just the rendering is incorrect.

    Apart from this, placement of combining characters in mintty is kind of weird unless a precomposed character exists as supplied by Windows (there is an explicitly request for that in the code). I'll investigate and maybe open a separate issue for it.

  9. mintty commented on Jun 27, 2016

    @mintty
    Owner

    Consider the sequence a͡x͡ ͡

    U+0061 LATIN SMALL LETTER A
    U+0361 COMBINING DOUBLE INVERTED BREVE
    U+0078 LATIN SMALL LETTER X
    U+0361 COMBINING DOUBLE INVERTED BREVE
    U+0020 SPACE
    U+0361 COMBINING DOUBLE INVERTED BREVE
    

    in either Consolas or Droid Sans Mono fonts.
    Positioning of the combining mark over the characters (with Droid Sans Mono even over the two letters) is inconsistent and often outside the character cell.
    Also the base letter appears to be rendered smaller with an accent. This is mangled by Windows (ExtTextOut), not mintty.
    I guess this combining character rendering problem cannot be solved unless other methods of text display are used (#438, #430).

  10. mintty commented on Jul 1, 2016

    @mintty
    Owner

    Combining characters are now drawn separately which seems to make them appear properly.
    Hopefully that does not interfere with any script-specific handling (like reshaping, but that's processed with precedence, transforming to presentation forms that are not subject to the tweaked handling).

  11. mintty commented on Jul 7, 2016

    @mintty
    Owner

    Released in 2.4.0.

  12. ElvenSpellmaker commented on Jul 11, 2016

    @ElvenSpellmaker
    Author

    @mintty: I've just downloaded the latest version and the original sequence I posted still appears the same way? Is that intentional?

    image

    And below I ask someone which one (first is the way you suggested, second way is the way that is the accepted way)
    image

    Someone else just replied back with:

    Same as <blah> for rendering here
    Linux mint 17.2 and gnome terminal 3.6.1
    

    My font is Consolas by the way.

  13. mintty commented on Jul 11, 2016

    @mintty
    Owner

    The longer "image" looks absolutely correct, as I had explained above.
    It does not look like that with other fonts, though.
    Also I'll need to revert the separate drawing of combining characters mentioned above since it makes some combining characters better but others worse (#565).

  14. ElvenSpellmaker commented on Jul 13, 2016

    @ElvenSpellmaker
    Author

    I have finally found out the problem with this COMBINING DOUBLE INVERTED BREVE.

    It's a character which combines on both sides. So in this case it should be combining to both the space and the degree symbol.

    I found this out by looking at an article for the "Tie" which is a non-combining version of the combining breve, found here: https://en.wikipedia.org/wiki/Tie_(typography)#Undertie.

    If you look in this text, you'll see the sequence of a<combining double inverted breve>b:

    U+0061 - LATIN SMALL LETTER A
    U+035C - COMBINING DOUBLE BREVE BELOW
    U+0062 - LATIN SMALL LETTER B
    

    image

    If you look at the Unicode data for this character (from the Unicode Database (located here: http://www.unicode.org/Public/UCD/latest/ucd/UnicodeData.txt) you get the following:
    0361;COMBINING DOUBLE INVERTED BREVE;Mn;234;NSM;;;;;N;;;;;

    The 234 here is what's known as a combine class.

    When searching what the 234 means I found this book: Unicode Demystified: A Practical Programmer's Guide to the Encoding Standard.

    It explains on page 179 that classes 233 and 234:
    image

    The wording is pretty bad, but it's saying the mark should appear above both characters, taking char 1 as the base, and char 2 as the second char. <letter><diacritic><letter>.

    Also, for characters in the character class, this might help: https://www.compart.com/en/unicode/combining/234

  15. ElvenSpellmaker commented on Jul 13, 2016

    @ElvenSpellmaker
    Author

    And here's a bit more information from https://en.wikipedia.org/wiki/Diacritic#Types.

    If you see here, it says it should be over two characters (which seems to be pretty poorly rendered with the dotted circles:
    image

    EDIT: As something to note, FireFox seems a lot better at rendering these marks and the first picture shown above (a + double inverted combining breve + b) is a lot better rendered:
    image

  16. mintty commented on Jul 14, 2016

    @mintty
    Owner

    Thanks a lot for these valuable references.
    After some experiments, I believe the desired rendering cannot be achieved with the ExtTextOut API currently used. Alternatives would be, in increasing order of API complexity and insanity:

  17. mintty commented on Sep 20, 2016

    @mintty
    Owner

    Please check the new support for "combining double" characters.

  18. mintty commented on Oct 7, 2016

    @mintty
    Owner

    Released in 2.6.2.

  19. mintty commented on Nov 12, 2016

    @mintty
    Owner

    Dropped experimental option WideIndic (and WideExtra) in favour of dynamic switching escape sequences, so an application can control the behaviour. An unaware application would just be confused by those options.
    Released in 2.7.0.

  20. reopened this on Nov 12, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions