Search Unity

TextMeshPro and best way to handle CJK unified ideograph in fallbacks

Discussion in 'UGUI & TextMesh Pro' started by ged_games, Jan 15, 2021.

  1. ged_games

    ged_games

    Joined:
    Aug 23, 2020
    Posts:
    5
    Hello

    I'm facing an issue with Chinese, Japanese and Korean font fallbacks on some characters :

    For example
    char.JPG
    is used both in Chineese & Japanese


    I have set my main SDF font to Latin (white material for the sample), then fallback on Korean (red material), Japaneese (yellow material) and Chinese (pink material);

    Latin (NotoSans-SemiCondensedExtraBold) (white)
    |_ Korean (NotoSansCJKkr-Bold) (red)
    |_ Japanese (NotoSansCJKjp-Bold) (yellow)
    |_ Chinese (NotoSansCJKsc-Bold) (pink)

    Fallback_config.JPG

    Other infos :
    • Atlas population mode is static for all, filled with the characters used.
    • Font used is from Noto Family
    • Text Mesh Pro text is set to Latin font
    • RTL Text Mesh Pro extension is used

    When I want to display a text containing this unified ideograph in Chinese, it seems that it fallback both on font Japanese (glyph is there) AND Chinese (for others glyphs), leading to an increase in loaded fonts and big memory footprint :

    Text_displayed.JPG
    (color yellow from japanese fallback, color pink from chinese fallback)

    So my question :

    What is the best way to handle this same characters in CJK with fallbacks, and not load both japanese and chinese fonts to display only chinese ?

    Thank you for your help
     
  2. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    Is there a reason to keep this glyph in the Japanese font asset given it is already contained in the Chinese font asset? Moreover since these font assets are static and prepopulated, is there a reason to have duplicate glyphs between them?

    Although this would result in this glyph coming from the same Chinese font asset fallback, the Japanese font asset fallback would still be loaded given it is referenced as a fallback to the primary and searched for potential glyphs.

    The bulks of the memory overhead related to these font asset fallback will be the texture. What is the size of those static font assets?
     
  3. ged_games

    ged_games

    Joined:
    Aug 23, 2020
    Posts:
    5
    Hello Stephan, thank you for your reply.

    Maybe I'm misunderstanding how TextMeshPro handle memory allocation, and profiling in the editor is misleading.
    1. In case of font fallbacks, are they all allocated in memory at start ? Or dynamically ? (if glyph is not found in primary, then create fallback1 and if not found, then create fallback2...)
    2. If Atlas population mode is static for SDF, is the TTF font file still included in the build and used runtime ? (I have seen weird examples where TTF and SDF atlas both exist in apk. I'm using addressable prefab containing tmpro text with those font falbacks )
    atlas_and_font.jpg

    Could you please explain what kind of object is allocated (atlas, texture..) and when ?, in my example if I want to display this common cjk character ?

    Latin
    |_ Korean
    |_ Japanese
    |_ Chinese

    Thank you Stephan