Class UnityTextMeasurementUtils
Measurement helpers for TextMeshPro texts, shared by every module that sizes rects around
TMP labels.
Inheritance
UnityTextMeasurementUtils
Assembly: Serenity.UnityGlobal.Infrastructure.dll
Syntax
public static class UnityTextMeasurementUtils
Methods
ComputePreferredWidth(TMP_Text, string)
Computes the single-line width content would render at, using
text's current font, font size and style. Callers that measure a worst-case width
(e.g. before auto-sizing shrinks a label) pass a probe already configured at its maximum font size.
Declaration
public static float ComputePreferredWidth(TMP_Text text, string content)
Parameters
| Type |
Name |
Description |
| TMP_Text |
text |
|
| string |
content |
|
Returns
ComputeSingleLineHeight(TMP_Text)
Computes the text's worst-case single-line height: the auto-size ceiling (fontSizeMax)
scaled by the font's real faceInfo lineHeight/pointSize ratio -- script fonts carry ratios well
above the 1.25 fallback used when no font is resolvable. Rects sized from this can never trigger
TMP's vertical whole-line cull at any size auto-sizing may settle on.
Declaration
public static float ComputeSingleLineHeight(TMP_Text text)
Parameters
| Type |
Name |
Description |
| TMP_Text |
text |
|
Returns