Search Unity

TextMesh Pro Help with International Phonetic Alphabet symbols in TextMeshPro

Discussion in 'UGUI & TextMesh Pro' started by JackGoeree, Feb 14, 2020.

  1. JackGoeree

    JackGoeree

    Joined:
    Mar 21, 2019
    Posts:
    5
    Hi all,

    I'm working on a language learning game in Unity. One of the features I'm trying to implement is a popup panel showing the pronunciation of a foreign word when you click on the word. The only issue I'm running into is getting the IPA symbols to display correctly in a TextMeshPro UGUI.

    Here's an example of what should be showing when a user clicks on the Czech word 'moci':
    [ˈmot͡sɪ]
    And here's what does show:
    [◻mot◻s◻]

    I've tried different fonts that supposedly have IPA support without success. Any ideas?
     
  2. Stephan_B

    Stephan_B

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    3,945
    Can you provide me with a link to one of those fonts as well as the character sequence to type to get this IPA string?
     
  3. JackGoeree

    JackGoeree

    Joined:
    Mar 21, 2019
    Posts:
    5
    Here is one of the fonts I've tried: https://software.sil.org/charis/

    The text I want is [ˈmot͡sɪ].
    The hexadecimal unicode value for that is:
    \u005b\u02c8\u006d\u006f\u0074\u0361\u0073\u026a\u005d
     
    Last edited: Feb 15, 2020
  4. Stephan_B

    Stephan_B

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    3,945
    Sorry that it took me longer to get to this...

    (1) I imported the font file CharisSIL-R.ttf.
    (2) Created dynamic font asset using the context menu Create - TextMesh Pro - Font Asset or CTRL - SHIFT - F12.
    (3) Created new text object and assigned this new font asset to it.
    (4) Copy / pasted "\u005b\u02c8\u006d\u006f\u0074\u0361\u0073\u026a\u005d" which produced

    upload_2020-2-18_13-2-59.png

    Please give the above steps a try. Please be sure to use the latest release of the TMP package which is version 1.5.0-preview.4 for Unity 2018.4, version 2.1.0-preview.4 for Unity 2019.x and 3.0.0-preview.4 for Unity 2020.x.
     
    JackGoeree likes this.
  5. JackGoeree

    JackGoeree

    Joined:
    Mar 21, 2019
    Posts:
    5
    Thanks for the response.

    Those were the steps I'd taken without any luck. However after updating Unity and the TMP package, the IPA symbols worked for all fonts. I hadn't updated TMP in a while so that must have been the issue. Thanks a lot; I hadn't considered that my TMP might me outdated.

    EDIT: While the example I gave was fixed by the update, I'm now having issues with other characters (almost all) in the IPA. Two symbols that still don't display properly, for example, are 'ɲ' (\u0272) and 'ɛ' (\u025b).
     
    Last edited: Feb 19, 2020
  6. Stephan_B

    Stephan_B

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    3,945
    Here is what I get using the same font asset.

    upload_2020-2-19_12-20-6.png

    Are those what you would expect?
     
  7. JackGoeree

    JackGoeree

    Joined:
    Mar 21, 2019
    Posts:
    5
    Yes, that's what I'm aiming for. I'm still getting empty squares though. Normal text boxes (not TMP) do display all the symbols correctly.
     
  8. Stephan_B

    Stephan_B

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    3,945
    Assuming you created a dynamic font asset as I described in my previous post (step 2), that should all work as expected with TMP.

    If you are getting the missing square glyph, then make sure the correct font asset is assigned to your text object. Make sure it is set to dynamic or that you have already added all those glyphs and characters in the font asset. If it is set to dynamic and you still get the missing square, then make sure the texture isn't full of other glyphs. If the atlas texture is full, you can then create a dynamic fallback and assign it to that font asset or enable Multi Atlas mode on that primary dynamic font asset.

    All that to say that it should work. We just to figure out which is the above might have the cause of those glyphs not showing up.
     
    JackGoeree likes this.
  9. JackGoeree

    JackGoeree

    Joined:
    Mar 21, 2019
    Posts:
    5
    Thank you for the great suggestions.

    I managed to fix the issue. The font asset was missing the characters I wanted.

    As an aside, I realise now that the non-TMP textbox was able to show the IPA characters (even with them missing from the font asset) because it used a fallback - the IPA characters didn't match the style of the rest of the font.
     
  10. Stephan_B

    Stephan_B

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    3,945
    Correct. The Legacy text system / UI Text will end up potentially using some fallback but you have no real control over it. With TMP, if the glyph is missing from the source font file, it will show you the missing glyph symbol but that is only after it has looked through the list of local fallbacks that you may have assigned to this primary font asset. Followed by checking if the local sprite asset that may have been assigned to the text object contains a sprite with this unicode value and then checking the Global list of fallback in the TMP Settings, then the global sprite asset, then the default font asset and then lastly display whatever missing glyph you have assigned to be displayed in the TMP Settings. Ie. Most importantly, lots of ways for you to control exactly what happens and when.
     
unityunity