Search Unity

TextMesh Pro Font Weights (typefaces) and how to use them

Discussion in 'Unity UI (uGUI) & TextMesh Pro' started by Cleverlie, Jun 22, 2019.

  1. Cleverlie

    Cleverlie

    Joined:
    Dec 23, 2013
    Posts:
    196
    Hi, I was wondering if there is an easy way to use the different font weights that you can assign to the font asset, I mean, if I have Roboto-light, Roboto-bold, Roboto-medium etc, then I can assign them in the "Font Weights" section of my "Regular" version, then when I activate the Bold option on the text object it will use the Bold font instead of the regular one. the same goes if I use the rich text "<b>" tags.

    I wonder how can I do the same but for the other weights, other than bold, such as Light, Medium, Heavy, etc.

    cheers!
     
  2. Stephan_B

    Stephan_B

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    3,187
    Support for all font weights is available in the latest releases of TMP. That would be version 1.4.x for Unity 2018.3 or newer and 2.0.x for Unity 2019.x.

    upload_2019-6-23_9-9-27.png

    In these latest releases, you would create font assets using these correct font weight typeface and assign it to the appropriate font weight in the font asset inspector.
     
  3. Cleverlie

    Cleverlie

    Joined:
    Dec 23, 2013
    Posts:
    196
    Hi Stephan, yes this is what I've been doing, what I'm asking is actually how to use them, I mean you know how you can use the "<b>" tags or the "B" button in the TMPUGUI object inspector to set all or a part of your text to bold weight, how can we do the same to set it to light, heavy, medium etc.

    is there such thing like a <medium-weight> tag or a button to change the weight? thanks for the help!
     
  4. Stephan_B

    Stephan_B

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    3,187
    There is indeed. The tag is <font=weight=xxx>. Here is another example

    "A<font-weight=500>B</font-weight>C"

    upload_2019-6-24_9-26-49.png

    upload_2019-6-24_9-28-12.png
     
  5. Cleverlie

    Cleverlie

    Joined:
    Dec 23, 2013
    Posts:
    196
    oh amazing! that's exactly what I've been looking for! I also realized that the text object has a fontWeight property that I guess it can override the rich text tags and set the overall weight too.

    thanks again, I really love TMP and how you thought about every aspect, the UX is near perfection, is one of that assets so good that you wish Unity integrates it out of the box.. oh wait! they already did it!

    cheers.