Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Displaying Foreign Languages in WebGL

Discussion in 'WebGL' started by tliu7, Sep 23, 2020.

  1. tliu7

    tliu7

    Joined:
    Jul 30, 2020
    Posts:
    2
    I am translating a game into Simplified Chinese. Characters in scripts and unity objects display just fine in the PC-built. However, the WebGL-built would not display correctly (They are ignored—no space or random texts).

    I did some digging, and it appears WebGL does not have access to the font in OS as the pc-built does.

    To fix that, I import a font that supports simplified Chinese into the assets folder. For unity objects, I can change the default font (Arial) to the font (Microsoft YaHei) I imported.

    However, for the characters in scripts, the documentation (https://docs.unity3d.com/2017.3/Documentation/Manual/class-Font.html) says you need to save the C# code in UTF-16 encoding for Unicode support. I did that, but the codes will not compile. I think this is not the issue cause the pc-built works just fine.

    From my searches in the unity forum, it appears there is an order of fallback fonts unity uses. I chose Microsoft YaHei because it is on that list. Yet, the WebGL-built will not display correctly even I had the TTF file imported and try different settings. Change the font property like “character” from dynamic to Unicode or ASCII.

    I also manually defined the fallback order by importing both Arial and MS-YaHei. It still does nothing.

    Here are some posts in the forum regarding similar issues.

    https://answers.unity.com/questions/931515/enabling-unicode-in-html5-builds-1.html
    https://forum.unity.com/threads/webgl-fallback-font-not-displaying-in-build-again-i-know.881818/
    https://forum.unity.com/threads/font-issue-with-webgl-although-i-added-the-font.526008/
    https://forum.unity.com/threads/fallback-font-not-used.582295/
    https://forum.unity.com/threads/japanese-hiragana-characters-dont-work-in-webgl.356097/

    Any feedback or suggestions are welcomed! Thank you.
     
  2. jinxed_byte

    jinxed_byte

    Joined:
    Mar 29, 2014
    Posts:
    17
    Have you tried this?
     
  3. tliu7

    tliu7

    Joined:
    Jul 30, 2020
    Posts:
    2
    Thank you. I will look into that. The majority of translation is done in C# codes. Would TextMeshPro work as well?