penpot_measure_text
Measure the exact width and height of text strings for any font, using Google Fonts or team fonts, to ensure accurate text placement in Penpot shapes without guesswork.
Instructions
Measure the real rendered width/height of a text string for a given font, without creating or touching any shape. Tries Google Fonts first (by family name, no API key needed); if the family is not on Google Fonts, searches all Penpot teams accessible to the configured token for a matching custom/team font. Computes glyph advance widths so the numbers match what Penpot would actually render — removing the guesswork around width/height when calling penpot_add_shapes or penpot_update_shapes for a text shape. Splits on explicit "\n" for multi-line text; pass maxWidth to also get word-wrapped line breaks for a fixed-width box. Returns { width, height, lineHeight, lines }, where width/height are the natural (or wrapped) bounding box and lines is a per-line breakdown of text/width.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| fontSize | No | ||
| maxWidth | No | ||
| characters | Yes | ||
| fontFamily | No | Inter | |
| fontWeight | No | 400 |