measure_text
Measure text dimensions without rendering it to size panels or center labels accurately, avoiding guesswork and re-rendering.
Instructions
Measure text without drawing it.
Use this to size a panel or centre a label in one shot instead of guessing and re-rendering.
Args: text: The string to measure font: Font name from list_text_fonts, or a path to a .ttf/.otf or bitmap font directory size: Pixel size for TrueType fonts; integer scale factor for bitmap fonts (default 1) letter_spacing: Extra pixels between glyphs (default 0) bold: Faux-bold passes; each grows strokes by 1px (default 0) antialias: Keep greyscale edges instead of hard pixels (default False)
Returns: width, height, advance_width, and the ink extents above/below the baseline.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| bold | No | ||
| font | Yes | ||
| size | No | ||
| text | Yes | ||
| antialias | No | ||
| letter_spacing | No |