Search Unity

TextMesh Pro Questions regarding Font Faces

Discussion in 'UGUI & TextMesh Pro' started by _watcher_, Dec 14, 2020.

  1. _watcher_

    _watcher_

    Joined:
    Nov 7, 2014
    Posts:
    261
    Hi,

    How to use Font Weights in TMPro? The documentation doesn't answer my questions.

    To explain, i have multiple font files, each of the files is a specific font weight (My Font-Regular, My Font-Bold, My Font-ExtraLight, My Font-Heavy, ..).

    1A) Can these be packed into single Atlas to save on DrawCalls?

    At the moment, i pack them separately (didnt find a way to pack together), and use them like this:
    Code (CSharp):
    1. i am regular
    2. <font="My Font-Light SDF">i am light</font>
    3. <font="My Font-Bold SDF">i am bold</font>
    1B) In case im just blind and they can be packed together, how do i switch the weights on the fly? (example: "Hello <face="Bold">world!</face>" - not in documentation)

    2) The Font Asset does contain Faces, and Fall Back fonts with their faces. But in case of my font, the different faces are very unique to the regular font face. The documentation seems to state that these Face references will only be used for dilation and spacing - honestly i'm unsure if the glyphs inside the different faces are even used - and if they are, doesn't explain how to switch between them in a textfield (1B).

    Help!
     
    Last edited: Dec 14, 2020
  2. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    They cannot at this time but this is something functionality that I am considering adding in the future.

    You can use the <font-weight=700> tag. Font weights value range is 100 - 900.

    This requires assigning a font asset in the font weight table of the font asset.

    upload_2020-12-14_13-29-10.png


    By font asset does contain faces... do you mean the font file you are using is a TrueType Collection (.ttc) file?

    If so, TMP does not currently loading these different font faces. However, this is a feature coming soon as seen below where you will be able to pick the specific font face form a .ttc font file.

    upload_2020-12-14_13-33-12.png

    The above new feature will require a new version of Unity and TMP package.
     
    _watcher_ likes this.
  3. _watcher_

    _watcher_

    Joined:
    Nov 7, 2014
    Posts:
    261
    Thank you @Stephan_B, for answering my questions!

    I later came upon some older threads where you already discussed this functionality (the thread was about how the number of draw calls matters much less than in the past, for slow devices). So this is not such a big issue. This answers the first question.

    This is great! it answers the other 2 questions i had. You might want to add the tag into the table here. Are there other tags perhaps, that are recognized by TMPro, but not in the table yet? That table is great way to organize the supported tags and has helped me a lot!

    Just ignore this completely i spoke out of my ***. The assets i'm using is each font (ttf or something) is a specific weight. Switching weights via <font/> tag -- well i saw how you split the text into separate fields when multiple weights are used in text -- i guess this is for batching - which i still am having mild problems with (but that's for a separate thread).

    Thanks for answering my questions!
     
    Last edited: Dec 15, 2020