Question

What is the text size in TMPro?

Answer and Explanation

In TextMesh Pro (TMPro), text size isn't measured in pixels directly, unlike typical image-based text rendering. Instead, TMPro uses a concept of font size relative to the transform scale of the text object and font asset metrics.

Here's a breakdown of how it works:

1. Font Asset Metrics: TMPro utilizes pre-calculated font metrics stored in the font asset file. These metrics, like em square, line height, and character advances, guide the rendering.

2. Font Size Parameter: You specify the text's desired size through the 'fontSize' parameter. This size isn't directly equivalent to a physical unit (like pixels) but works proportionally. For example, in Unity’s Inspector window of a TMPro object, a text size of 16 is quite common. When you change this number you modify the overall size of the characters drawn by TMPro.

3. Text Scale and Text Rendering: TMPro calculates actual rendered size based on this "fontSize", plus additional scaling parameters applied through its transform in Unity. A ‘scale’ on the gameobject can also influence final appearance size, this also contributes to the text's overall appearance size in world or screen units.

4. Unit Flexibility: While no explicit pixel sizes, this method means TMPro text doesn't pixelate when scaled in contrast to rendering a regular texture containing font as image.

5. Common Sizes and Use Cases A 'size 10', or 12 can be commonly used when doing UI elements for your project, the ideal is to play and adjust the size while visually testing how that integrates into your game or program interface.

In summary, the text size you specify in TextMesh Pro controls a logical size according to pre-defined parameters which the actual drawing and rendering engine translates it using its rendering routines and taking account any scale or transforms that are in play.

More questions