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

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

2 Likes

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 Likes

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?

6 Likes

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.

@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. :slight_smile:

1 Like

Those warnings can be disabled in the TMP Settings.

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

3 Likes

It would be nice to have it on a per font basis then, instead of disabling it for all fonts. Would that be possible?

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.

1 Like

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.

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.

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”
11 Likes

Actually disabling the warning in the TMP settings does nothing for me, it still displays it.

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.

3 Likes

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.

        protected void GetUnderlineSpecialCharacter(TMP_FontAsset fontAsset)
        {
            bool isUsingAlternativeTypeface;
            // Search primary font asset for underline character while ignoring font style and weight as these do not affect the underline character.
            TMP_Character character = TMP_FontAssetUtilities.GetCharacterFromFontAsset(0x5F, fontAsset, false, FontStyles.Normal, FontWeight.Regular, out isUsingAlternativeTypeface);
            /*
            if (m_Underline.character == null)
            {
                // Search primary fallback list
                if (fontAsset.m_FallbackFontAssetTable != null && fontAsset.m_FallbackFontAssetTable.Count > 0)
                    m_Underline.character = TMP_FontAssetUtilities.GetCharacterFromFontAssets(0x5F, fontAsset.m_FallbackFontAssetTable, true, m_FontStyleInternal, m_FontWeightInternal, out isUsingAlternativeTypeface, out tempFontAsset);
            }
            // Search TMP Settings general fallback list
            if (m_Underline.character == null)
            {
                if (TMP_Settings.fallbackFontAssets != null && TMP_Settings.fallbackFontAssets.Count > 0)
                    m_Underline.character = TMP_FontAssetUtilities.GetCharacterFromFontAssets(0x5F, TMP_Settings.fallbackFontAssets, true, m_FontStyleInternal, m_FontWeightInternal, out isUsingAlternativeTypeface, out tempFontAsset);
            }
            // Search TMP Settings' default font asset
            if (m_Underline.character == null)
            {
                if (TMP_Settings.defaultFontAsset != null)
                    m_Underline.character = TMP_FontAssetUtilities.GetCharacterFromFontAsset(0x5F, TMP_Settings.defaultFontAsset, true, m_FontStyleInternal, m_FontWeightInternal, out isUsingAlternativeTypeface, out tempFontAsset);
            }
            */
            if (character != null)
            {
                m_Underline = new SpecialCharacter(character, 0);
            }
            else
            {
                if (!TMP_Settings.warningsDisabled)
                    Debug.LogWarning("The character used for Underline is not available in font asset [" + fontAsset.name + "].", this);
            }
        }

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. :slight_smile:
Cheers

I disabled the warnings, but now every font just doesn’t load ad looks like the deafult arial

1 Like

I agree, this should be changed to only show warning when there is an actual issue.

1 Like