Search Unity

TextMesh Pro Control margin when using <mark>

Discussion in 'UGUI & TextMesh Pro' started by tylkomat, Jul 16, 2020.

  1. tylkomat

    tylkomat

    Joined:
    Jun 17, 2019
    Posts:
    22
    WhatsApp Image 2020-07-16 at 09.57.32.jpeg

    Is there a way to achieve the space between text (0.7 Kilo) and borders of the mark? Currently I fake it using a character (_) before and after the <font>-tag. Since the mark is 100% solid color that char is hidden.

    Code (HTML):
    1. <mark=#28283C>_<font=LiberationSans SDF><b><color=#ffffff>0.7 Kilo</font></color></b>_</mark>
    Is there a better way to do it? I tried <space> and <margin>, but none of them worked.
     
  2. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    Yes. Use the padding attribute as per the following example

    <mark=#ff800080 padding="2,2,2,2"> ... left, right, top, bottom.
     
    cxode likes this.
  3. tylkomat

    tylkomat

    Joined:
    Jun 17, 2019
    Posts:
    22
    Does this need a newer version than 2.0.1?
     
  4. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    I think so... It is for certain in 2.1.0.
     
  5. cxode

    cxode

    Joined:
    Jun 7, 2017
    Posts:
    268
    Hey @Stephan_B , would it be possible to add support for font units on mark padding? Instead of just pixels
     
  6. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    I gather you like font units :)

    I'll look at adding it to the next release.
     
    cxode likes this.
  7. cxode

    cxode

    Joined:
    Jun 7, 2017
    Posts:
    268
    Haha, indeed I do. Thanks very much <3
     
  8. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    Just took a quick look at this and the <mark> tag padding values are already in font units but the values are 1/100 em. So if the text object point size is 100 and the padding values 1, 1, 1, 1 then it will add padding of 1 pixel or 1/100 of 100 point size.

    So the new question is whether or not I should add support for pixel units? If I make any changes, it will break / change the padding for everyone using this as the values are currently declared in pixel unit style but are em based.

    If I do add the "em" modifier then do I stick to 1/100 em?
     
  9. cxode

    cxode

    Joined:
    Jun 7, 2017
    Posts:
    268
    In my opinion, the spacing should be consistent across all rich text tags. So without the
    em
    tag it should be pixels, and with the tag it should be full font units, not 1/100 font units.

    But of course, this would be a breaking change and screw up mark padding for anyone using that feature. For my own projects I think the change is worth it, and I'd be happy to update everything in exchange for consistent formatting. But others may not agree.
     
  10. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    In the Inspector, the spacing values are all 1/100 em. However, in many of the tags, which predate these changes they were in full em so I'll take a look to try to make sure everything is consistent.

    I am working on the new preview series where although I most certainly want to avoid breaking changes, this would be the time to review / further improve on the consistency of those values / tags.
     
    cxode likes this.