Search Unity

Is 16mb font file size acceptable? How to work with CJK fonts

Discussion in 'UGUI & TextMesh Pro' started by unadamlar, Feb 26, 2020.

  1. unadamlar

    unadamlar

    Joined:
    Jul 7, 2015
    Posts:
    10
    I'm working on a mobile game and I want to keep my build size as low as possible. I will have users with CJK names and I want to be able to display their names in their own languages in the game.

    I'm working with dynamic SDF in regards to the TMP font asset so the font atlas size is no issue but the source font itself has a too big size.

    I'm using NotoSansCJKtc-Regular.otf which has a file size of 16mb. This contributes too much to the build size and I don't want it to increase that much.

    Is there any way to work around this issue? Or is this tradeoff of the font size the usual way to deal with this. I'm really baffled because a 16mb font would mean about 15% of the size of my game which is really really large.
     
    Baydogan and tvilarinhoAquiris like this.
  2. crazybeek

    crazybeek

    Joined:
    Aug 23, 2012
    Posts:
    46
    Did you find a solution for this?
    We have 4 Asian fonts of 16mb each in our build (otf files) on top of the 4 generated Font assets of 4mb each.
    I wonder if it's possible to get rid of the 64mb of otf files... and just keep the 16mb of textmesh pro assets Font assets.
     
  3. unadamlar

    unadamlar

    Joined:
    Jul 7, 2015
    Posts:
    10
    Unfortunately not. I have instead decided to just put both files into an asset bundle and let the user download the files at their own time. Please let me know if you figure out a proper solution for this
     
  4. Baydogan

    Baydogan

    Joined:
    Mar 22, 2018
    Posts:
    54
    Most of the CJK Fonts are more than 10MB each. Did anyone find a solution in the last two years?
     
  5. Mauri

    Mauri

    Joined:
    Dec 9, 2010
    Posts:
    2,665
    I don't think there's much that you can do - apart from removing unneeded glyphs. Asian languages generally just have waaay more characters than western languages.
     
  6. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    Remember that you can use Dynamic OS Font Assets which were introduced in the latest previews.

    Dynamic OS font assets behave exactly the same as Dynamic font assets in the editor. However, when creating a build, their source font file will not be included.

    At runtime, when requesting characters, and glyphs, TMP will search the OS fonts for a font with the same Family and Style name. If found on the target platform, it will use that file. Using Dynamic OS font assets allows you to leverage fonts already present on target platforms.
     
    Mauri and Baydogan like this.
  7. Baydogan

    Baydogan

    Joined:
    Mar 22, 2018
    Posts:
    54
    Thanks, @Stephan_B

    This is good news for me. I will try to use iOs and android supported fonts as these are the platforms I am targeting.

    But when I inspect the build report, unity includes even the fonts that I did not use or referenced anywhere.
    Maybe I am doing something wrong but this is also asked by other users.

    For example, I am using NotoSans-Bold SDF.asset but Unity also puts these TTF files to the build.

    NotoSans-Bold.ttf
    NotoSans-BoldItalic.ttf
    NotoSans-Italic.ttf
    NotoSans-Regular.ttf

    Any suggestions?
     
  8. Baydogan

    Baydogan

    Joined:
    Mar 22, 2018
    Posts:
    54
    @Stephan_B
    How does unity know the target platform/os level fonts at build time?
    Does text mesh pro keep an internal list of the font for each supported platform?
     
  9. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    If that font asset is dynamic, the font file will be included. If it is dynamic OS, it will not be included.

    If the ttf file is contained in a resources folder or referenced by any other object or asset, it will also be included.
     
    Baydogan likes this.
  10. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    We don't know. When your application is loaded on whatever target platform, we query the platform OS to get a list of fonts available. This query gets us the Family name and style name of the fonts so that when you have a dynamic OS font asset referencing the same family and style name, then we use that one.
     
    Baydogan likes this.
  11. kevinbunarjo

    kevinbunarjo

    Joined:
    Mar 23, 2022
    Posts:
    3
    I'm currently trying to add emoji fonts into our project and am running into the same issue where it is 16MB large. However, I'm unable to make the font dynamic. Do you know how I can enable this setting?
     

    Attached Files:

  12. manundi

    manundi

    Joined:
    Jun 30, 2019
    Posts:
    14
    Hello! I have tried to use TMPro New native Emojis with Atlas Population on Dunamic OS on WEBGL build.

    Want to report that it is not working as I expected.

    -> Looking for any other way to make emoji font smaller. -> ttf file is 4mb on my WebGl build. Without ttf file build is 10mb so it does make a difference.

    upload_2023-12-11_14-59-40.png