Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

TextMesh Pro Mono spaced font size on screen?

Discussion in 'UGUI & TextMesh Pro' started by andyz, May 10, 2020.

  1. andyz


    Jan 5, 2010
    I was trying to use a mono spaced font and know exactly how many rows & columns of letters I can fit in a screen area, but how do I do that?
    If the font size is 36 then it is 36 pixels tall but the line height is bigger and the [mono] letter width I don't know.
    How do you get these in the editor and at runtime?
  2. Stephan_B


    Feb 26, 2017
    Fonts come in all shapes and sizes where it is up to the font designer to stick or not to design standards. As such, you cannot assume that any given font at 36 point size will have a height of 36 points.

    To determine the exact line height of any given font asset, you have to look at the Line Height property.

    For instance, creating a font asset using the IBM Plex Mono font available on Google Fonts, we see that it has a line height of 117 at sampling point size of 90.


    This means that if the text object's point size is 90, the line height will be exactly 117 pixels from Baseline to Baseline.

    To determine the width of any given character, you also have to look at the metrics of that character. In the case of a Monospaced font, the advance value of each character should be the same. In the case of this IBM Plex Mono font with sampling point size of 90, the advance value is 54 or 54 pixels from characters' Origin to Origin.

    andyz likes this.