Search Unity

Bug Thin text when using "mark" style tag

Discussion in 'UGUI & TextMesh Pro' started by Nyankoooo, Dec 17, 2022.

  1. Nyankoooo

    Nyankoooo

    Joined:
    May 21, 2016
    Posts:
    144
    I'm currently facing an issue when using the "mark" style tag in my project. As far as I'm aware, we currently need to use a workaround to make the "mark" style tag work, as otherwise the mark-color would render above the text.

    This is what I'm currently using: <mark=#ffe589><font=Epkyouka Mark Workaround></font>です</mark>

    But instead of displaying normal, the text inside of the mark tag is thinner than the text outside of it. You can see this on the screenshot below.

    Both fonts, the original and workaround have the same font settings in the inspector.

    Does anyone know what could cause this or what I could try to make the text inside of mark tag the same thickness as outside?
     

    Attached Files:

  2. halley

    halley

    Joined:
    Aug 26, 2013
    Posts:
    2,433
    I'm not sure what the workaround is. Your <font> tag is being opened, then closed, before the です text, so you go back to the previous font.

    If this font-switch-trick lets you change the order of the text layering, great. I think what we see in the screenshot is an erosion of the thin strokes due to alpha cutoff / alpha blending of the font glyphs, versus a very similar color for the mark. If the text itself were black, does that change the weight of the thin strokes vs the mark rectangle?

    The Mark tag is documented as supporting alpha in the coloring, so <mark=#ffe58980> would make it 50% see-through. If that's all that was holding you back, experiment with the right color for your mark.
     
  3. Nyankoooo

    Nyankoooo

    Joined:
    May 21, 2016
    Posts:
    144
    That sounds like the issue with the mark tag was resolved at some point, thank you for pointing this out. I will give it a try and see how it works now! Thanks!
     
  4. Nyankoooo

    Nyankoooo

    Joined:
    May 21, 2016
    Posts:
    144
    @halley Quick update: using the mark tag with it's alpha value doesn't do the trick, as the mark overlays the text instead of being behind it. I know that this is the intended behavior as of the documentation, but when the workaround above got suggested, having the mark behind the text was the goal.

    I also quickly tried changing the text to black as you suggested, but the marked text is still displayed thinner.
     
  5. halley

    halley

    Joined:
    Aug 26, 2013
    Posts:
    2,433
    Not sure what else, then. It seems to be an alpha clipping erosion.

    If your camera is 2D or ortho, an ugly hack to make the mark REALLY behind the object would be to have two copies of the TMP, one in back with alpha zero text color but colorful marks, and one in front with desired text color and no marks. For short bits of text and not much action, it should be feasible.
     
  6. Nyankoooo

    Nyankoooo

    Joined:
    May 21, 2016
    Posts:
    144
    @halley How would you make the text color zero alpha but the marks still show up?
     
  7. halley

    halley

    Joined:
    Aug 26, 2013
    Posts:
    2,433
    Yup, that's a problem, just confirmed. Text color's alpha is applied to the mark color too. But you can set the color outside the mark and AGAIN inside the mark to keep the mark's alpha.



    Front TMP: OKAERINASAI
    Rear TMP: <color=#00000020>O<mark=#ff0000ff>KAERI</mark>NASAI



    Rear TMP: <color=#00000040>O<color=#000000ff><mark=#ff0000ff><color=#00000020>KAERI</color></mark><color=#00000020>NASAI

    (Change the #00000020 to just #00000000 for fully transparent text, I just did this for visibility.)
     
    Last edited: Dec 17, 2022
  8. Nyankoooo

    Nyankoooo

    Joined:
    May 21, 2016
    Posts:
    144
    @halley Makes sense, thank you for even doing screenshots of it, really appreciating it!
     
  9. Nyankoooo

    Nyankoooo

    Joined:
    May 21, 2016
    Posts:
    144