Search Unity

TextMesh Pro Zero-width space character is not zero width for monospace fonts

Discussion in 'UGUI & TextMesh Pro' started by KurtGokhan, Jul 19, 2020.

  1. KurtGokhan

    KurtGokhan

    Joined:
    Jan 16, 2013
    Posts:
    37
    I am using TextMesh Pro 3.0.0 UGUI component. "0x200B" character is not rendered in regular fonts as expected but it is rendered when the font is monospace. I don't know if this is a bug or the expected behavior. But to me it makes more sense if this character is zero-width even in monospace (that is the case in HTML).

    I locally fixed it by adding
     || charCode == 0x200B
    to TMPRO_UGUI_Private.cs line 2083.

    For the context, I am using this character for allowing words to line-break at certain points.

    Edit: The solution above makes the caret disappear when input field is empty.
     
    Last edited: Jul 19, 2020
  2. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    Do you mean when using <mspace> tag or with a particular font?

    If a particular font, please provide a link to this font file.
     
  3. KurtGokhan

    KurtGokhan

    Joined:
    Jan 16, 2013
    Posts:
    37
    @Stephan_B I am using the Roboto Mono font (Regular 400). Same thing also happens with <mspace> tag.

    See the example image. The first text is regular font and the second one is monospace font.


     
    Last edited: Aug 4, 2020
  4. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    Is your expectation that when using the Zero Width Space that it would remain zero width in all cases?
     
  5. KurtGokhan

    KurtGokhan

    Joined:
    Jan 16, 2013
    Posts:
    37
    @Stephan_B Yes, that is what I expected. All UI frameworks I checked render it as zero width, does not matter if the font is monospace or not.

    Sorry for the late reply.
     
  6. KurtGokhan

    KurtGokhan

    Joined:
    Jan 16, 2013
    Posts:
    37
    @Stephan_B any progress on this? Do you agree that it is a bug?
     
  7. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    That is an issue which I should be able to address in the next release.