Search Unity

TextMesh Pro Font units do not work with the <width> rich text tag

Discussion in 'UGUI & TextMesh Pro' started by cxode, Nov 16, 2020.

  1. cxode

    cxode

    Joined:
    Jun 7, 2017
    Posts:
    268
    From the documentation:
    <width>
    works fine with pixels and percentages, but it doesn't work for font units.

    upload_2020-11-15_21-48-33.png

    I would really appreciate some help here. I'm using 2019.4.11f1 with TMP 2.1.3.
     

    Attached Files:

  2. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    Some tags like <width> do not support all 3 of the unit types.

    I can certainly add em to the <width> tag.

    Just to confirm, if the current point size is 50pts then a <width=1em> will equal 50 pixels.
     
    cxode likes this.
  3. cxode

    cxode

    Joined:
    Jun 7, 2017
    Posts:
    268
    Thank you for the response. For my project, em support for <width> would be very useful and I do hope you add it.

    I understand that some tags do not support all 3 unit types, but the documentation specifically says that <width> supports them all, which is why I was confused.
     
  4. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    I added font unit (em) support to the <width> tag.

    Do you have a good use case / example of using em to define the width of the text container?
     
  5. cxode

    cxode

    Joined:
    Jun 7, 2017
    Posts:
    268
    Thank you very much, I appreciate it!!

    I want to use em for all my rich text tags because it is independent of the canvas scaling and the font size. It means I can change the font size and the text will still look the same just smaller. If I use pixels, then I have to change the rich text tags whenever I change the font size to get a consistent look.

    PS: sorry it took me a while to get back to you! Busy week.