Search Unity

Font issue with WebGL although I added the font

Discussion in 'Web' started by Deeaammon, Apr 9, 2018.

  1. Deeaammon

    Deeaammon

    Joined:
    Sep 20, 2012
    Posts:
    13
    Sorry if this question has been asked. I looked through the forums and didn't find it.

    So here is my situation,

    I am trying to use the arial font in unity in WebGL. The problem is that the unit default arial font does not work in unity. This is fine. I added the Arial.ttf font to my assets. This works as it uses the font and makes it look arial. However I am having to use some unicode coding to do subscripts and superscripts. This works fin in my editor or standalone versions but in WEBGL it doesn't work. It simply replaces the unicode code with nothing. For example if I have CO2 with the 2 as a subscript it renders CO. I've uploaded a jpg so you can see what I'm dealing with.

    I am having a hard time figuring it out.

    Does anyone have any ideas?

    Thanks
    Darrell
     

    Attached Files:

  2. JJJohan

    JJJohan

    Joined:
    Mar 18, 2016
    Posts:
    214
    font.png

    You'll want to make sure you configure the font to use Unicode, not 'Dynamic' which is the default. What this does is generate a texture with all the possible font characters based on the font size you have configured.

    The downside is if you've got wildly differing font sizes you'll want to generate separate textures for them, otherwise they will stretch/shrink and become blurry etc..
     
    Esbol and Deeaammon like this.
  3. Deeaammon

    Deeaammon

    Joined:
    Sep 20, 2012
    Posts:
    13
    OK. I have tried this but I"m still having problems. Now it appears that the new fonts I"m adding to my assets folder are not being used when I compile in webgl. Even though I have added them and changed the font on the text when I go to my program in webgl it reverts back to Arial. Again this only happens in webl. In my standalone projects it works just fine.
     
  4. saviemedia

    saviemedia

    Joined:
    Nov 8, 2016
    Posts:
    7
    Hello, I was able to fix the same problem with @JJJohan solution. I added arial font in the projet and used this one with the unicode setting. Thanks everyone!
     
  5. Esbol

    Esbol

    Joined:
    May 22, 2016
    Posts:
    3
    ThankYou so much!
    Due to the fact that texts were not displayed in WebGL, I threw 2 projects into the trash. This time I found your advice and saved me.