Search Unity

TextMesh Pro Fixed Value Width to create an Odometer scroll

Discussion in 'UGUI & TextMesh Pro' started by SciKip, Jul 11, 2019.

  1. SciKip

    SciKip

    Joined:
    Jul 11, 2019
    Posts:
    2
    I am using TMP to create an Odometer effect as I call up new values.
    As the font I am using (Arial Reg) has different width characters, my overall number slightly moves in and out along the characters. I would like this to stay constant (see a car odometer).

    Is there any way of maintain or setting a default constant size to my number values?

    Thanks!
    Kip
     
    BenR likes this.
  2. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    You can use the <mspace=x> </mspace> tag which forces mono spacing on the characters enclosed in the tag.

    You can also select a different font or make another font asset from this same font and edit the glyph's metrics such as xBearing and Advance values to normalize them to make sure everything lines up correctly.

    This uneven spacing is because of the font being proportional where each digit has different metrics.