Search Unity

TextMesh Pro TextMesh Pro - Rendering Unicode Charachters

Discussion in 'UGUI & TextMesh Pro' started by ZeroByter, Mar 2, 2018.

  1. ZeroByter

    ZeroByter

    Joined:
    Aug 3, 2014
    Posts:
    24
    Hello,

    I am trying to render a user's name in a TMPro text but it doesn't render well. I tried doing the same in a regular Unity text and it worked.



    I read about creating custom fonts, etc. But in this case I am trying to render user's inputs, and therefore I can't add fonts for every username possible.

    Is there a fix for this? Thanks.
     

    Attached Files:

  2. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,596
    In order for any given character to render, they have to be contained in the font asset that you are using. For most languages, creating a font asset that includes all the characters is not an issue given most languages don't actually contain that many characters.

    So for Latin based languages including Cyrillic and Greek, a single font asset or possibly a Primary with a Fallback font asset can easily handle this. They key here is knowing what unicode ranges these languages use. A list of all languages and their unicode ranges is available here.

    Where it gets trickier is with East Asian languages which have a much larger character set. For those, you will have to create a Primary font asset that contains all the characters used / known in your project for any given group of languages and then for user input characters create additional font asset that will be used as fallback. See the following video which covers some of this.

    I also recommend you watch the videos about font asset creation and material presets as those important concepts / functionality to understand.

    Now having said all of that and the underlying reason for your post / question is the result of TextMesh Pro not currently supporting any type of dynamic font atlasing where characters get added into a font atlas texture at runtime which is what the Unity's current font system does but at the cost of performance overhead. So without repeating / re-posting information I have posted before, a hybrid dynamic font atlasing system is in the works for the new text system that I am currently working on which will eventually replace both the legacy system and TextMesh Pro. I don't have an ETA yet on this but it is coming. I also might be able to introduce parts of this new system into TextMesh Pro but no promises there.

    Until the new system is available, every single language can be supported with TextMesh Pro but it does require more work in terms of preparing your font assets. On the flip side since these assets are prepared ahead of time, it provides for the best performance and quality on any platforms. There are several posts about this on the TextMesh Pro user forum and here which a quick search should reveal about Primary Font Assets, Fallback, etc. Now if you can't find what you need, that is what I am here for (besides working on the new system :) ).

    To learn / read more about this new system, see the following post.
     
    ina and bitinn like this.
  3. ZeroByter

    ZeroByter

    Joined:
    Aug 3, 2014
    Posts:
    24
    Is there a single math/Unicode font that covers all these special charachters?
     
  4. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,799
    The point is that you need to generate the font map to include those characters. From seeing the image above you just included some Greek characters in there and plenty of fonts have those.

    By the way, as an aside, please don't use greek characters as "stylised" English characters. I see the text in your screenshot and all I can read is LLISP IPSIDX.
     
    Stephan_B likes this.
  5. ZeroByter

    ZeroByter

    Joined:
    Aug 3, 2014
    Posts:
    24
    Alright, got it. Thanks for the help guys!
     
  6. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,596
    As per @AcidArrow post, there are plenty of source font files (.ttf / .otf) that include math symbols, music, etc.).

    You might need to get some font tool to view the content of the font file. Many of these are free. The demo of the High-Logic FontCreator works well. Another option could be https://fonts.google.com/ which is a good source of fonts with open license where you can also type sample text which would also enable you to verify if the characters you need are present in the font file.

    Alternatively, you could also use FontAwesome for symbols or even sprites using the <sprite> tag. Basically, you have several options here.