Search Unity

TextMesh Pro Outline/Underlay that isn't relative to font size?

Discussion in 'Unity UI (uGUI) & TextMesh Pro' started by AntoineDesbiens, Feb 4, 2018.

  1. AntoineDesbiens

    AntoineDesbiens

    Joined:
    Jun 9, 2014
    Posts:
    742
    If I have a text mesh with a font size of 30 and another with a font size of 60, the outline will look much thicker on the mesh with the bigger font size.

    While I understand why this behaviour can make sense, I'd like to know if it's possible to maintain the same thickness of outlines, no matter the font size, without using a custom material for every different sizes used.
     
  2. Stephan_B

    Stephan_B

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    3,193
    The ability to dynamically add an Outline, Underlay (Shadow) and other visual treatments is made possible by the use of Distance Field. This is done at the shader level and based on the material properties / values.

    Since this distance field information is encoded in the font atlas texture and relative to the ratio of Sampling Point Size to Padding, the effective range or thickness in the case of an Outline will remain consistent and proportional to the size of the characters / point size.

    Again since this is based on the material properties / values, you will need different materials to achieve different thickness.

    The UI - Effect - Outline FX is done by duplicating the geometry and then applying some offset. In the case of the Outline, this results in 5X the geometry count which can have massive performance impact on some devices. If you absolutely need a fixed pixel offset on these FX, you could implement something similar.

    Personally and from a design point of view, having the thickness of outline change with font size is strange as small text would appear to have a much thicker outline than larger text which again from my personal point of view would look weird.
     
  3. AntoineDesbiens

    AntoineDesbiens

    Joined:
    Jun 9, 2014
    Posts:
    742
    I sincerely appreciate the reply. I can deal with multiple materials. I just wanted to make sure I wasn't missing out on something.

    I'm not too sure about that. I think if you use the smaller text to define your outline width and then apply this everywhere, it can provide a feeling of consistency. Then again, this is all a matter of opinion.

    Thank you for your time!
     
  4. blackizzy

    blackizzy

    Joined:
    Dec 28, 2018
    Posts:
    1
    I agree with Antoine Desbiens, outline width would require more than often to have absolute size. Think of those as margin in design theory. Let's take a web page as example : no matter the size of a container if you decided to keep a margin of 10px between elements, it will stay consistent. With font, you can think of outline as 'separators' between the font and the background . So they need to remain consistent . Now we have to set like dozen of materials for different font size to keep them consistent.

    The problem with relative stroke size is also that when a font get very small, a low stroke width value would result in the stroke ending up interpolate too much with bg and look pale grey. And at the opposite, the smaller a font get, the more constrast it needs to being readable, and when we choose to have a stroke as a constrast element, we are in big troubles in this particular case.