Search Unity

[Solved] TextMeshPro - Text(UI): Shows empty squares

Discussion in 'UGUI & TextMesh Pro' started by denis-andreevich, Apr 27, 2020.

  1. denis-andreevich

    denis-andreevich

    Joined:
    Aug 21, 2016
    Posts:
    50
    I observe strange behavior. Certain letters can be replaced with an empty square. But this problem may not be present in a new empty scene or a new project. Example below.
    In the "Play" mode and after starting directly on your phone (Android), empty squares will be displayed.
    Ubuntu Linux 20.04, 2019.3.11f1, TMPro 2.0.1
     

    Attached Files:

  2. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    The empty square is the glyph that is displayed when TMP is unable to locate the character in the primary font asset or any potential fallback.

    The behavior should be consistent in the Editor and builds / platforms provided whatever font asset would are using in the editor is also included in the build.

    Does your font asset includes these characters (the ones replaced by the missing glyph)?

    Are you using any fallbacks?

    Are these fallback included in your build?
     
  3. denis-andreevich

    denis-andreevich

    Joined:
    Aug 21, 2016
    Posts:
    50
    At this stage of development, I use the standard liberation sans font. But the result is different in both the current and new projects
    upload_2020-4-28_10-43-32.png

    upload_2020-4-28_10-45-54.png
     
  4. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    What version of Unity and TMP is used in the top image vs. bottom image?

    Make sure you are using the latest version of TMP and TMP Essential Resources as older versions (in case you didn't update the TMP Essential Resources) LiberationSans was static and did not have any fallback. The newer version does use a fallback but you also need to make sure it is not full.

    If you can't figure out the issue, just submit a bug report with the project and steps to reproduce and I'll take a closer look.
     
  5. denis-andreevich

    denis-andreevich

    Joined:
    Aug 21, 2016
    Posts:
    50
    Ubuntu Linux 20.04, 2019.3.11f1, TMPro 2.0.1 both screen.
    Let's take it in order:
    I'm go to Window > TextMeshPro > Font Asset Creator. After, select font which has all Russian latters.
    upload_2020-4-28_13-14-58.png

    Next step is click Generate Font Atlas.
    upload_2020-4-28_13-16-26.png

    And i see, that one Russian letter "Ц" is missing. Next step is saving assets and add new font to component.
    Results after typing with new font below

    upload_2020-4-28_13-21-10.png

    We see, that missing letter now missing without empty squares.
     
  6. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    The character range that you are defining is missing "Ц" which is \u045F. The font asset is also missing glyph 0 which is the missing glyph (square).

    As of Unicode version 13.0 Cyrillic script is encoded across several Unicode ranges
    Instead of trying to create a static font asset that includes these range of characters where you may not be using all of them, you could:

    (1) Create a Dynamic Font Asset with Multi Atlas Texture enabled in the Font Asset Inspector in the Generation Settings. You would use this font asset during development. Then at some point, switch to using a Static Primary font asset that includes the main Cyrillic character range of \u0400 to \u04FF which would be combined with a Dynamic Font Asset using the same font file to handle all other potential Cyrillic characters as needed. Be sure to match the sampling point size to padding ratio between the Primary and Dynamic Fallback.

    or (2)
    Assuming you want to support Latin + Cyrillic, and wanted to use some other font file that includes support for Cyrillic, you would create a Primary Static Primary font asset the includes the Extended ASCII range. You would add a static font asset the includes the Cyrillic main character range of 0400 - 04FF to it as fallback. You would a dynamic font asset to handle all other potential Latin and Cyrillic characters and assign it to your static primary.

    Here is an example of that structure using LiberationSans.

    The primary static font asset below includes the Extended ASCII using Sampling Point Size of 80 with padding of 8 (10% ratio). Notice how the static Cyrillic font asset is assigned to it as fallback.

    upload_2020-4-28_2-40-5.png


    The static Cyrillic font asset includes 400-4FF with Sampling Point Size of 70 with padding of 7 (10% ratio)

    upload_2020-4-28_2-40-17.png

    Lastly the dynamic font asset to catch all other characters potentially contained in the LiberationSans font file is using Sampling of 80 with padding of 8 (10% ratio) with Multi Atlas texture enabled

    upload_2020-4-28_2-40-52.png

    These 3 font assets will be able to display all characters contained in LiberationSans.

    There are other ways this could be structured.

    See the following videos which describe how we can use the Dynamic SDF system to handle CJK and many other languages.



     
    AeOngDev, art092 and denis-andreevich like this.
  7. denis-andreevich

    denis-andreevich

    Joined:
    Aug 21, 2016
    Posts:
    50
    Thanks for your reply. I have a better understanding of how the component works. Now I have all the necessary letters displayed, including special characters.
     

    Attached Files:

    Stephan_B likes this.