Search Unity

TextMesh Pro The character used for Underline and Strikethrough is not available in font asset

Discussion in 'UGUI & TextMesh Pro' started by LesBloom, Oct 21, 2019.

  1. LesBloom

    LesBloom

    Joined:
    Feb 2, 2017
    Posts:
    167
    Hello,

    I recently updated Unity and now get these warnings printed quite frequently.

    I don't understand why the new version of TMP requires a font to have these 2 characters. I have many fonts in my project and very few of them ever use these characters. Therefore they are not included in the font. My thought process is that I would rather either save texture space or use that texture space for higher res versions of characters that actually get used.

    I can see that TMP_Settings.warningsDisabled is a way to avoid this particular warning. However, I don't want to miss out on real warnings just to disable this particular output.

    I don't understand why these specific characters are needed.

    Is it so important that this is an error and I should add these characters?

    Thank you
    Lester
     
    Gamadrila likes this.
  2. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    Just like all other characters, the Underline and Ellipsis characters are specific to each font file and can vary greatly in terms of design and metrics from one font to another.

    As such, when you select Underline or use Ellipsis, TMP will try to use the appropriate Underline and Ellipsis character. For this to work with static font assets, these characters have to be present in the font file. If they are not, TMP will issue a warning if not disabled in the TMP Settings.

    The reason you are seeing these warnings now is simply because such warnings were disabled by default in the TMP Settings before.
     
  3. LesBloom

    LesBloom

    Joined:
    Feb 2, 2017
    Posts:
    167
    Shouldn't it only print the warning if the font tries to display one of those characters then?

    These fonts are never displaying those characters. As far as I understand it; there is nothing to actually be warning me about. Right?
     
    Havie, Flavelius, trombonaut and 2 others like this.
  4. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    TMP tries to load and cache these special characters when the font is referenced by TMP.

    I do plan on re-working this handling in the future. In the short term and has it was previously, it is best to disable the warnings in the TMP Settings or to add those characters to those specific fonts.
     
  5. ManuelRauber

    ManuelRauber

    Joined:
    Apr 3, 2015
    Posts:
    122
    @Stephan_B It would be nice, if you could rework this. If using Font Awesome Pro, you don't need those special characters, but you still get the warning all time. :)
     
    trombonaut likes this.
  6. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    Those warnings can be disabled in the TMP Settings.

    The challenge is that some users want to get those warnings and others don't.
     
  7. ManuelRauber

    ManuelRauber

    Joined:
    Apr 3, 2015
    Posts:
    122
    It would be nice to have it on a per font basis then, instead of disabling it for all fonts. Would that be possible?
     
  8. Gillissie

    Gillissie

    Joined:
    May 16, 2011
    Posts:
    305
    This warning message would be much more useful if it told us what the required character was, so we could add it if we want it. I've tried underscore and em-dash, but both still don't fix it.
     
    Gamadrila likes this.
  9. Gillissie

    Gillissie

    Joined:
    May 16, 2011
    Posts:
    305
    Ok, apparently you need to restart Unity for the font to recognize the underscore character after you've added it. The font doesn't re-cache it when you re-build the font.
     
  10. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    Make sure you are using the latest release of the package for the version of Unity you are using which is : version 1.5.1 for Unity 2018.4, version 2.1.1 for Unity 2019.x and version 3.0.1 for Unity 2020.x.

    In terms of character / glyph additions, clicking any properties of the text object in the inspector like one of the alignment ones, should refresh the text object. If that fails, entering ans existing play mode does re-load the font assets.

    Let me know if the above worked for you.
     
  11. Walo_de_Cole

    Walo_de_Cole

    Joined:
    Feb 21, 2021
    Posts:
    2
    In version 2020.3, you can disable TMP warnings following these steps:
    - Window->Text Mesh Pro->Import TMP Essential Resources
    - Import (button)
    - Select TMP Settings in Asset > TextMesh Pro -> Resources (folder)
    - Under the header Dynamic Font System Settings select "Disable warnings"
     
    amyscorpion, Zemyx, Tunamy and 7 others like this.
  12. pragmascript

    pragmascript

    Joined:
    Dec 31, 2010
    Posts:
    107
    Actually disabling the warning in the TMP settings does nothing for me, it still displays it.
     
  13. MartinH8921

    MartinH8921

    Joined:
    Aug 27, 2021
    Posts:
    8
    The instructions you provided didn't seem to work for me in Unity 2021.3
    I was able to find it by going to project settings -> TMP -> check the box to disable warnings. This worked.
     
    CringeItIn, spaghettiSyntax and efge like this.
  14. daxiongmao

    daxiongmao

    Joined:
    Feb 2, 2016
    Posts:
    412
    I am getting this. But I think its not searching the full fallback structure.
    My default font asset is empty. It does not contain any atlas. It just points to all the fallbacks to be used.
    Code (CSharp):
    1.  
    2.         protected void GetUnderlineSpecialCharacter(TMP_FontAsset fontAsset)
    3.         {
    4.             bool isUsingAlternativeTypeface;
    5.             // Search primary font asset for underline character while ignoring font style and weight as these do not affect the underline character.
    6.             TMP_Character character = TMP_FontAssetUtilities.GetCharacterFromFontAsset(0x5F, fontAsset, false, FontStyles.Normal, FontWeight.Regular, out isUsingAlternativeTypeface);
    7.             /*
    8.             if (m_Underline.character == null)
    9.             {
    10.                 // Search primary fallback list
    11.                 if (fontAsset.m_FallbackFontAssetTable != null && fontAsset.m_FallbackFontAssetTable.Count > 0)
    12.                     m_Underline.character = TMP_FontAssetUtilities.GetCharacterFromFontAssets(0x5F, fontAsset.m_FallbackFontAssetTable, true, m_FontStyleInternal, m_FontWeightInternal, out isUsingAlternativeTypeface, out tempFontAsset);
    13.             }
    14.             // Search TMP Settings general fallback list
    15.             if (m_Underline.character == null)
    16.             {
    17.                 if (TMP_Settings.fallbackFontAssets != null && TMP_Settings.fallbackFontAssets.Count > 0)
    18.                     m_Underline.character = TMP_FontAssetUtilities.GetCharacterFromFontAssets(0x5F, TMP_Settings.fallbackFontAssets, true, m_FontStyleInternal, m_FontWeightInternal, out isUsingAlternativeTypeface, out tempFontAsset);
    19.             }
    20.             // Search TMP Settings' default font asset
    21.             if (m_Underline.character == null)
    22.             {
    23.                 if (TMP_Settings.defaultFontAsset != null)
    24.                     m_Underline.character = TMP_FontAssetUtilities.GetCharacterFromFontAsset(0x5F, TMP_Settings.defaultFontAsset, true, m_FontStyleInternal, m_FontWeightInternal, out isUsingAlternativeTypeface, out tempFontAsset);
    25.             }
    26.             */
    27.             if (character != null)
    28.             {
    29.                 m_Underline = new SpecialCharacter(character, 0);
    30.             }
    31.             else
    32.             {
    33.                 if (!TMP_Settings.warningsDisabled)
    34.                     Debug.LogWarning("The character used for Underline is not available in font asset [" + fontAsset.name + "].", this);
    35.             }
    36.         }
    37.  
    38.  
    With includeFallbacks set to false.
    Is there a reason for this really? To not search for these in the fallbacks?

    Actually looks like the code is already there to do it. just commented out?
    This code is old and does not compile, but it seems GetEllipsisSpecialCharacter does exactly that already. @Stephan_B Can you see about updating this in the get underline special character?

    So I don't have to maintain a custom package. :)
    Cheers
     
    Last edited: Aug 14, 2022
  15. MKrzysiek

    MKrzysiek

    Joined:
    Aug 11, 2022
    Posts:
    2
    I disabled the warnings, but now every font just doesn't load ad looks like the deafult arial
     
    APTEM59 likes this.
  16. OndraPaska

    OndraPaska

    Joined:
    Jul 5, 2014
    Posts:
    13
    I agree, this should be changed to only show warning when there is an actual issue.
     
    tamdevx likes this.