Search Unity

Getting TMPro to use the whitespace character from font?

Discussion in 'UGUI & TextMesh Pro' started by ciathyza, Feb 21, 2019.

  1. ciathyza

    ciathyza

    Joined:
    Aug 16, 2015
    Posts:
    112
    Is there any way to get TMPro to use the whitespace character specified in a font? It seems it simply inserts its own spacing between words where a whitespace is placed.

    The reason is this: I want to use a font that uses two variations: a regular one and an inverse one that is, well, an inverse version of the regular font. When the inverse version is used all characters affected by it are inverse except the whitespace between words. To have it look properly the whitespace has to be inverse too however.
     
  2. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,596
    TextMesh Pro does use the space character (0x20) and other whitespace characters defined in the source font file (if present of course).

    You can also add and edit characters, glyphs and their metrics in the Font Asset Editor.
     
  3. ciathyza

    ciathyza

    Joined:
    Aug 16, 2015
    Posts:
    112
    Hi Stephan! It doesn't seem to be the case though...

    I have the whitespace included in my inverse font SDF but the space between words when using this font still appears as not using the inverse whitespace. Please see my screenshots to know what I mean...

    http://files.ciathyza.com/wl/?id=MLh26wSpyr0PAaJ5JnFqGyhcc5BBmV2U
    http://files.ciathyza.com/wl/?id=1A1Drxtd5UbFp4zM8YwRxZveTxYvnlWU

    Not sure if I'm missing a detail here to get this working properly.
     
  4. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,596
    What version of TextMesh Pro are you using?

    and can you PM me a link to this font so I can check it out?
     
  5. ciathyza

    ciathyza

    Joined:
    Aug 16, 2015
    Posts:
    112
  6. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,596
    Thanks for providing a link to the font as it enabled me to figure out what the actual source of the behavior.

    As it turns out, TextMesh Pro does correctly retrieve the space character and glyph from the font file as you can see below.

    upload_2019-2-22_0-49-35.png

    However, the reason why the character is not visible is because geometry for Whitepace characters (which are not usually visible) is never created as you can see below.

    upload_2019-2-22_0-54-56.png

    I need to think about how to handle this one.

    I could add an option in the TMP Settings like "Generate Geometry for Whitespace characters". That option would be global and affect all font assets which is not ideal.

    The option to create geometry for whitespace characters could be added to font assets or on a per character basis in the Character Table where by default whitespaces have this flag set to false and other characters to true.
     
    Last edited: Feb 22, 2019
  7. ciathyza

    ciathyza

    Joined:
    Aug 16, 2015
    Posts:
    112
    Thanks for investigating this issue! Do you have any roadmap or schedule when this fix might make it into a release?
     
  8. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,596
    The current behavior is by design as creating geometry for characters that are not visible would be inefficient so this is not a bug.

    In terms of adding functionality to allow special handling of whitespace like in this use case, I don't have an ETA but will certainly look into it and provide feedback as soon as I have more information.
     
  9. ciathyza

    ciathyza

    Joined:
    Aug 16, 2015
    Posts:
    112
    Thanks a lot! I'm looking forward to see support for whitespace characters being added.
     
  10. Nerull22

    Nerull22

    Joined:
    Dec 31, 2010
    Posts:
    14
    Apologies for resurrecting this dead thread. But I've been looking through the font files, settings and what not for a while now and was not able to find anything about generating meshes for white space characters. I am attempting to do the same thing listed here in setting a glyph for the space character (hex unicode value 0020), but as stated here, since there is no mesh generated, I'm not able to place a symbol in place of that. We are using a "Custom Language" font where a symbol is in place of spaces.

    @Stephan_B was this ever added, if so where? If not, is it on a roadmap?