Search Unity

Bug Glyphs present in both dynamic and static font assets are not rendered when using the latter (if)

Discussion in 'UGUI & TextMesh Pro' started by Starbox, Dec 3, 2021.

  1. Starbox

    Starbox

    Joined:
    Sep 17, 2014
    Posts:
    469
    ... using decimal or Unicode ranges to extract the characters and having no default font in TMP Settings.

    Context:
    I'm testing font files, largely in the Noto family right now, for languages such as Russian, Arabic or Chinese and I noticed a serious issue.

    So let's create a TMP text area.
    Paste a paragraph of Arabic words.
    Use a dynamic version of a Noto that's capable of supporting its characters and apply it to the TMP component.
    Everything works, text is fully visible.

    Arabic characters are in the Unicode range 0600-06FF.
    It can be verified when reading the glyph table, they are all variations of 06xx.

    Now, create a static asset.
    Three methods I used thus far:
    1. Use the corresponding decimal range (see here).
    2. Use the proper Unicode range.
    3. Use custom characters, namely, here, the text displayed in the component.
    With option 1 and 2, all characters are found but when applying the asset into the component, many characters are not displayed. There is no missing symbol (square). It's just that many characters are not found despite the fact that they are clearly listed in the glyph table. TMP seems to be replacing them with empty space (blanks).
    All glyphs being stored on a single atlas use the index 0 which is fine. They are all scaled at 1 too.

    But when creating the font file with the second method, from the text itself, then it works properly.
    However this method is absolutely not practical at all because the text has to be extracted from whatever file is used in Unity to populate the string fields (dialogues, menus, etc.).

    The issue is "solved" if I put a font asset in TMP Settings' default slot, regardless of the font used or its character generation mode (dynamic vs static).
    I had put this slot to "none" to make these tests with the idea of avoiding any possible disturbance because it is not clear how TMP manages this default font asset in light of the purity of other new custom font assets users can create. I notice that depending on the asset being declared, characters will be slightly displaced horizontally.

    I also noticed that there are in fact two default font files, somehow used in a sort of fallback mode: The explicit one, found in this top slot in TMP Settings, and the implicit one that relies on Liberation in TextMesh Pro > Resources > Fonts & Materials.

    Unity 2019.4.30f1, TMP 2.1.6.
     
  2. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    The fallback search sequence for requested characters is as follows:

    1. Search primary font asset
    2. Search list of local fallback assigned to the primary. List is search recursively start with first fallback and its own potential fallbacks, then second fallback.
    3. Search local sprite asset assigned to text object along with any of its potential fallbacks. We search sprite asset because they may contain sprites with the requested unicode.
    4. Search global fallback list in the TMP Settings. Search is similar to local fallbacks.
    5. Search default sprite asset assigned in the TMP Settings along with any of its potential fallbacks.
    6. Search default font asset assigned in the TMP Settings along with its potential fallbacks.
    7. Display the missing glyph defined in the TMP Settings.