Search Unity

TextMesh Pro Would it be possible to compute the font-size or the text size given the font asset ?

Discussion in 'UGUI & TextMesh Pro' started by bali33, May 6, 2021.

  1. bali33

    bali33

    Joined:
    Aug 14, 2011
    Posts:
    232
    Hello,

    In order to be able to apply constraints like having a group of different TextMeshPro having the same font-size to pre-compute the font size each text would have with a specific text and then be able to select the lower-one and applied it to all of them. It would be very useful when working with localized text for which the font-size auto is set to true.

    Is that possible to "simulate" how the TextMeshPro properties without having to render it ?

    Thanks
     
  2. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    See the following post as it might prove useful to you.

    In terms of simulating stuff, I would suggest using a single text object with the "renderMode" property set to "
    TextRenderFlags.DontRender".

    In theory, you would use this text object and set its properties. You would then use ForceMeshUpdate() to force it to update before the camera is rendered. This would enable you to then check the content of its textInfo, preferred values, point size, etc. and then disable the object after as to not have it render at all.
     
    bali33 likes this.
  3. bali33

    bali33

    Joined:
    Aug 14, 2011
    Posts:
    232
    Thanks