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

TextMesh Pro Chinese font problems

Discussion in 'UGUI & TextMesh Pro' started by elpuerco63, Oct 16, 2017.

  1. elpuerco63

    elpuerco63

    Joined:
    Jun 26, 2014
    Posts:
    271
    I search for a .ttf Chinese font online and import into my project. I then use it to in the Font Asset Creator and every time the image on the right shows plain English characters?

    Then if I try to update the material it always automatically switches back to LiberationSans SDF

    Totally confused, can some one help please, I really need to use Chinese characters in my app :-(

    Thanks
     
  2. elpuerco63

    elpuerco63

    Joined:
    Jun 26, 2014
    Posts:
    271
    I found an online tutorial that shows how to use Font Asset Creator but regardless of font I choose and I see the atlas is created when I enter my Chinese in the TMP field all I see in the editor in my scene is a bordered square?

    Can seem to get Chinese to appear at all?
     
  3. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    What character range are you using to define the Chinese character set?

    Note that not all fonts include Chinese characters so you have to make sure you pick an appropriate font.

    See the following post with additional information.
     
  4. elpuerco63

    elpuerco63

    Joined:
    Jun 26, 2014
    Posts:
    271
    Thanks, I've tried at least 4 different fonts that are Chinese ones and although I get the atlas create WITH the characters I pasted in as the custom characters I still only get the blank square.

    I've since ditched this approach and am using images instead as wasting too much time on TMP, which is a shame :-(
     
  5. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    There are now 10's of thousands of developers using TMP with all these different languages. Once the font asset is created and includes the necessary characters, it should work. Did you take the time to watch the video about Font Asset Creation? You must be missing a step in this process.

    If you post an image of the Font Asset Creator window with the settings you are using and an image of the Text object with that font asset assigned to the text object I might be able to see why it is not working for you.
     
  6. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    Here is an example of some Chinese text that I grabbed from Blizzard's website.

    upload_2017-10-17_13-41-37.png

    Here are the settings I used to create this font asset where I simply copy / pasted the characters I needed.

    upload_2017-10-17_13-41-6.png

    and lastly the text object settings which show that I am using this newly created font asset.

    upload_2017-10-17_13-42-55.png
     
  7. elpuerco63

    elpuerco63

    Joined:
    Jun 26, 2014
    Posts:
    271
    Thanks! I will revisit, appreciate the help :)
     
  8. dominikusdp

    dominikusdp

    Joined:
    Nov 3, 2016
    Posts:
    1
    Hi All, I want to make TMP Font for Chinese (both Simplified and Traditional), anyone know where can I get the full list for custom character list for Chinese font?

    Thank you.
     
  9. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
  10. The-Scripter

    The-Scripter

    Joined:
    Nov 10, 2009
    Posts:
    30
    Has anyone been able to use TextMeshPro to import a Chinese font? @Stephan_B thanks for linking to that table, but how can we use it to import a character set? You were able to import a font with enough characters to show specific text, but how can I allow users to write names or chat?

    I have been searching the forums but I still have no idea how to include the necessary characters.
     
  11. elpuerco63

    elpuerco63

    Joined:
    Jun 26, 2014
    Posts:
    271

    OK so in my setup I am using the font 华文楷体.tff but I do not know what to select in the Character Set option, currently ASCII which explains a lot! How would I know what custom characters to put in? Does TMP not read the tff file?
     
  12. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    Including all Chinese characters in a font asset when a project might only be using less than a thousand would be very inefficient.

    For instance the Chinese language includes over 60,000 characters. However as it turns out only about 8105 of those have actually been found in electronic communication. This is known as the list of General Standard Chinese Characters which are the only ones you really need to focus on. See my reply above which references this table of characters.

    I have also made several posts (see this one for example) about how to setup font assets to handle Chinese, Japanese and Korean which consists of creating a primary font asset which contains all the known / used Chinese character in the project and then create a few additional fallback that will contain the remaining characters from the table of general standard Chinese characters.
     
  13. elpuerco63

    elpuerco63

    Joined:
    Jun 26, 2014
    Posts:
    271
    Kudos! Thank you, perfectly answered :)
     
    Deleted User and Stephan_B like this.
  14. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    If the Font Asset Creator indicates they were included, you should be able to see them in the atlas texture? Are you able to see them in the atlas?

    Can you provide me with a link to this font? I'll try creating a font asset from it and use the same characters.
     
  15. elpuerco63

    elpuerco63

    Joined:
    Jun 26, 2014
    Posts:
    271
    Hi, the font is 华文楷体.tff, Im looking for a download but no luck yet, can I copy it to you somewhere? It looks like the issue is in the Unity Editor and if I close the scene and reopen then they start to appear?
     
  16. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    You can send me a private message and include a link to the font.
     
  17. elpuerco63

    elpuerco63

    Joined:
    Jun 26, 2014
    Posts:
    271
    Did you see my PM?
     
  18. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    I did not.

    Thank you for the reminder.
     
  19. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    I finally had a chance to look into this and the characters all render correctly once added to the font asset. Here is an example below.

    upload_2018-8-19_14-36-31.png

    It is important to note that using Chinese characters in file names is problematic. Not sure if this is specific to Unity or C# API for finding file path but for the time being it is best to avoid using non Latin character in file names.

    The font file that you referenced is either STKaiti or derived from it. After renaming the font file to STKaiti (ie. some Latin based file name) I was able to create the font asset and to include the characters you mentioned were still showing as missing.

    Let me know if you need further assistance on this?
     
  20. Subhojit

    Subhojit

    Joined:
    May 17, 2014
    Posts:
    9
    I am trying to paste Hindi font from Microsoft word document but the characters are not showing. It is showing bunch of boxes. Another thing is I can type the font in Unity editor but that also not correct. Is there any other process that I can follow. Please help. I am attaching some images for reference.
     

    Attached Files:

  21. Wainor

    Wainor

    Joined:
    Jul 31, 2018
    Posts:
    1
    How display Chinese in Text Mesh Pro?
    Please help me.
    Thanks for any help.
     
  22. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    I have made several posts about this topic describing how to handle CJK with the previous version of TextMesh Pro and newer versions which include the Dynamic SDF system.

    See the following post in this thread above as well as this other post.
     
  23. LegendaryHero

    LegendaryHero

    Joined:
    Feb 27, 2019
    Posts:
    3
    Hi, Stephan_B!

    I am making a game MOD these days. The requirement is: replace the original Font in the game with the Chinese Font Font Asset made by TexMesh Pro in the way of AssetBundle hot update package. Since there is no source code of the game, you can only directly modify the Assembly-CSharp-firstpass.dll. I have tried to modify the LoadFontAsset method of the TextMeshProUGUI class as follows:

    Original code snippet:
    Code (CSharp):
    1.     protected override void LoadFontAsset()
    2.     {
    3.         ShaderUtilities.GetShaderPropertyIDs();
    4.         if (m_fontAsset == null)
    5.             {
    6.                 if (TMP_Settings.defaultFontAsset != null)
    7.                     m_fontAsset = TMP_Settings.defaultFontAsset;
    8.                 else
    9.                     m_fontAsset = Resources.Load<TMP_FontAsset>("Fonts & Materials/LiberationSans SDF");
    10.                 if (m_fontAsset == null)
    11.                 {
    12.                     Debug.LogWarning("The LiberationSans SDF Font Asset was not found. There is no Font Asset assigned to " + gameObject.name + ".", this);
    13.                     return;
    14.                 }
    15.                 if (m_fontAsset.characterDictionary == null)
    16.                 {
    17.                     Debug.Log("Dictionary is Null!");
    18.                 }
    19.                 m_sharedMaterial = m_fontAsset.material;
    20.             }
    21.  
    The modified code snippet:
    Code (CSharp):
    1.     protected override void LoadFontAsset()
    2.     {
    3.         ShaderUtilities.GetShaderPropertyIDs();
    4.         if (m_fontAsset == null)
    5.             {
    6.                 AssetBundle assetBundle = AssetBundle.LoadFromFile(Path.Combine(Application.dataPath, "Mods", "font"));
    7.                 this.m_fontAsset = assetBundle.LoadAsset<TMP_FontAsset>("msyh SDF");
    8.                 assetBundle.Unload(false);
    9.                 if ((UnityEngine.Object) this.m_fontAsset == (UnityEngine.Object) null)
    10.                 {
    11.                   this.m_fontAsset = UnityEngine.Resources.Load<TMP_FontAsset>("Fonts & Materials/LiberationSans SDF");
    12.                   if ((UnityEngine.Object) this.m_fontAsset == (UnityEngine.Object) null)
    13.                   {
    14.                     Debug.LogWarning((object) ("The LiberationSans SDF Font Asset was not found. There is no Font Asset assigned to " + this.gameObject.name + "."), (UnityEngine.Object) this);
    15.                     return;
    16.                   }
    17.                 }
    18.                 if (m_fontAsset == null)
    19.                 {
    20.                     Debug.LogWarning("The LiberationSans SDF Font Asset was not found. There is no Font Asset assigned to " + gameObject.name + ".", this);
    21.                     return;
    22.                 }
    23.                 if (m_fontAsset.characterDictionary == null)
    24.                 {
    25.                     Debug.Log("Dictionary is Null!");
    26.                 }
    27.                 m_sharedMaterial = m_fontAsset.material;
    28.             }
    29.  
    Good recompile the Assembly-CSharp-firstpass.dll file into the game testing, I expected effect is through in the run-time dynamic loading game contains msyh SDF.asset AssetBundle font file, the file absolute path is "Application.dataPath/Mods/font", achieve the goal of uniform use of msyh SDF in the game this Font Asset; After debugging, I can be sure that my modified method has been executed correctly, but found that all the fonts in the game are not displayed any more! Could you please tell me how to modify it to achieve the desired effect? Is my modification method incorrect? Looking forward to your reply, thank you!
     
    Last edited: Mar 2, 2019
  24. RedCabinGames

    RedCabinGames

    Joined:
    May 8, 2016
    Posts:
    7
    For anyone else finding this thread, we were having issues even after following all of these instructions and trying different fonts. For us we had to increase the Atlas Width and Atlas Height settings on our NotoSansSC-Regular SDF font that we were using from 2048 to 4096 and all the missing characters started to show.

    Hope that helps!
     
  25. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    Have you tried enabling Multi Atlas Texture on a font asset that would be 1024 x 1024?
     
  26. RedCabinGames

    RedCabinGames

    Joined:
    May 8, 2016
    Posts:
    7
    I have not, but I can't find that option anywhere on my font asset.
    I'm on Unity 2018.4.13 and TMPro 1.4.1.
     
  27. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    Latest version of TMP for Unity 2018.4 is version 1.5.6. There are significant changes between 1.4.1 and 1.5.6 so be sure to read the ChangeLog first and backup the project.
     
  28. AdminBag

    AdminBag

    Joined:
    Sep 19, 2016
    Posts:
    18
    Hi Stephan_B we have a problem with Tex mesh pro Atlas and Chinese character.

    We make the atlas with all the text i have in game and it works, but we have input fields where the player can write a name and there we have the square-missing-font problem because we do not know which name the player will type.

    CatturaCina.PNG

    Is there a solution to have all characther in the atlas?
     
  29. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    Since the Chinese language contains over 72,000 characters, it is not possible to fit all of those in a single atlas. The simplest solution is to add a dynamic font asset as fallback to your primary font asset that contains all your text.

    If you are not familiar with fallback font assets and all please take the time to watch the following two videos.



     
    ageana, Omid7L and FloBeber like this.
  30. AdminBag

    AdminBag

    Joined:
    Sep 19, 2016
    Posts:
    18
    Thank you so much for the reply!
     
  31. david-milian

    david-milian

    Joined:
    Jul 13, 2019
    Posts:
    6
  32. hughperkins

    hughperkins

    Joined:
    Dec 3, 2022
    Posts:
    191
  33. zezba9000

    zezba9000

    Joined:
    Sep 28, 2010
    Posts:
    985
    Use Googles Nono Sans fonts which support all langs with a consistent look.
    TBH Unity needs to provide some pre-baked ones for TMP. Korean for example has a lot of characters & took my computer over 24 hours to bake a 8k texture for them.