Search Unity

TextMesh Pro Confused about Upper/Lower case display

Discussion in 'UGUI & TextMesh Pro' started by LilGames, Apr 18, 2019.

  1. LilGames

    LilGames

    Joined:
    Mar 30, 2015
    Posts:
    570
    Hi I'm not quite understanding something basic: I created a font texture using the generator and only included UPPERCASE letters in the font texture. Then I created a TMP text field, typed in both upper and lowercase letters and set the font to the one I generated. The font style appears correct to me, but both upper and lowercase letters appear in both Scene and Game view. If only uppercase is in the texture atlas, how is it possible I am seeing lowercase letters as well?

    Please help me understand what is going on here. This is only the second time I've "dabbled" with TMP, but I understand in principle how it all works. I am expecting ONLY uppercase would appear, if lowercase were missing from the atlas. Please explain why this is not the case.
     
  2. LilGames

    LilGames

    Joined:
    Mar 30, 2015
    Posts:
    570
    Hmm... I've examined the game objects and I noticed that a second shader gets automatically created that contains all the letters in it if I click any of the upper/lower buttons below "Font Style". This is somewhat misleading... That second shader does not get deleted if I turn off aB AB and SC. Shouldn't there be a warning before just automatically adding a new font set?
     
  3. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    TextMesh Pro has a fallback system where TMP will search through the potential fallbacks to find the potentially missing characters which in this case are the lowercase letters.

    When searching for potential missing characters, TMP will:
    (1) first look for any potential fallbacks assigned to the fallback list of the primary font asset (the one assigned to the text object). It will search this list recursively starting with the first going through their own potential fallbacks as well.

    (2) it will search the Sprite Asset (if any) assigned to the text object in case some of those sprites have been assigned a unicode value that would match this character.

    (3) It will search the general fallback list in the TMP Settings in a similar recursive manner.

    (4) It will search the default sprite asset assigned in the TMP Settings in case any of those sprite have been assigned the given unicode.

    (5) It will search the default font asset in the TMP Settings and its own potential fallbacks as well.

    (6) Lastly, it will display the missing glyph defined in the TMP Settings.

    Note that Sprite Assets can have fallbacks of their own.

    Now in your case, the lower case letters would have been coming from the LiberationSans font asset which is the default font asset assigned in the TMP Settings.

    Whenver Sprites or characters from a fallback font assets are needed, a sub mesh object is created to contain their geometry. Users do not need to manage these sub mesh objects as they are created as needed and unless needed / used have not impact on performance or anything.
     
    LilGames likes this.
  4. LilGames

    LilGames

    Joined:
    Mar 30, 2015
    Posts:
    570
    What about on file size and texture memory? Does TMP "clean up" after itself as well?
     
  5. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    The clean up cost of sub mesh objects (deleting them and potentially having to recreate them again) is more costly then leaving them in place with their geometry degenerated (where all vertices are set to zero thus being ignored by the graphic card).

    Sub mesh objects use material instances that point to existing atlas textures of font assets. The number of sub mesh objects doesn't affect texture memory.
     
    LilGames likes this.