Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

How to add Unicode characters to TextMesh Pro?

Discussion in 'UGUI & TextMesh Pro' started by kiferdon, Apr 6, 2020.

  1. kiferdon

    kiferdon

    Joined:
    Aug 14, 2018
    Posts:
    15
    TextMesh Pro 2.0.1
    I work on random generated strings. The problem is many symbols can't be shown. Instead I see white emty box.
    upload_2020-4-6_19-16-49.png
    This image is for characters from 375 to 1000. Character below are showing fine.
    What should I do to include these characters too? I've already generated font atlas with following settings:
    upload_2020-4-6_19-23-30.png
    When I load characters 375-100 there are a lot of missing characters.
    upload_2020-4-6_19-29-45.png
    I guess, characters are missing from the Robot font. Maybe there is font with big part of Unicode characters?
     
    Last edited: Apr 6, 2020
  2. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    Roboto does indeed only support a few languages. Take a look at Google's NotoSans font family available on Google Fonts as it support all languages. However, this font comes in multiple potential font files some for specific languages.

    Google Fonts also allows you to find fonts for specific languages in case you are looking for different visual designs.

    P.S. Also be sure to switch to using version 2.1.0-preview.8 available via the package manager.
     
    kiferdon likes this.
  3. kiferdon

    kiferdon

    Joined:
    Aug 14, 2018
    Posts:
    15
  4. kiferdon

    kiferdon

    Joined:
    Aug 14, 2018
    Posts:
    15
    What is the general approach to "missing characters" problem?

    1) Searching missing charactes on Google Fonts
    2) Downloading fonts which has character
    3) Generating Font Asset and setting as Fallback to your main font?

    What if you can't find missing character in any other font? Maybe there is a way to check if character is missing from current font at runtime?
     
  5. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    (1) Choosing the right font(s) with the required character coverage for any given language is key and sometimes challenging. It can also be challenging to find fonts that work well together from a visual / design standpoint when the primary font may not contain all the characters you need.

    Although fonts can vary greatly from one another, you can normalize their metrics in the font asset inspector to make them blend better with each other as you go from primary to fallbacks.

    See the following post related to potential structure of these font assets and fallbacks.

    The Font Asset API has functions to check what characters are contained in the font asset but the key is really to make sure you select font files that have the required glyph coverage. As per the linked post, your font assets and the fonts you selected should contain all the characters used in the project for any given language or groups of languages which you will be able to verify / test before shipping. For characters coming from user input, you will need to make sure you have a font file used as fallback that has the appropriate coverage. Fonts like NotoSans do include font files to support all languages. Most of the time you don't want to include all these font files in your build but instead use AssetBundle or other potential mechanism to load these resources as needed based on user language selection. Most of this is also covered in the other post I linked.