Text Measurement

Your AI assistant uses this tool to measure how tall text will be before placing it on a slide — avoiding overflow and positioning elements precisely on the first pass.

When building a slide with multiple elements stacked vertically — a title, an accent line, then body text — your assistant needs to know how much space each piece of text occupies. slides_measure_text returns estimated dimensions for up to 20 texts in one call, so the assistant can calculate positions accurately before creating any elements.

This is especially useful for layouts where element positioning depends on content height — something the assistant can't know until the text is measured.

Measuring Text Before Placing It

Parameters

ParameterTypeRequiredDescription
deckIdstringNoOptional deck ID. When provided, measurements account for the deck's font scale factor (relevant for imported templates with non-standard canvas sizes)
measurementsarrayYesArray of texts to measure (1–20 items)

Measurement Object Properties

Each item in the measurements array describes a piece of text and its container:

PropertyTypeRequiredDescription
textstringYesMarkdown text to measure (same format as element creation)
fontSizenumberYesFont size in points
widthnumberYesContainer width in pixels
heightnumberNoContainer height in pixels. If provided, checks for overflow. Omit to just get the estimated text height
fontFamilystringNoFont family name. Uses a default sans-serif heuristic if omitted
shapeTypeenumNo'rectangle', 'circle', or 'diamond'. Adjusts for the inscribed text area (circles and diamonds have less usable space)
textInsetsobjectNoPadding: { left, top, right, bottom } in pixels (defaults: 10px horizontal, 5px vertical)
lineSpacingnumberNoLine spacing multiplier (default 1.0)
paragraphSpacingobjectNo{ before, after } in points (default: 0)

What It Returns

For each measurement, the response includes:

  • estimatedHeight — how tall the text will be in pixels
  • estimatedLines — number of lines the text wraps to
  • availableWidth — usable width after insets (and shape adjustment)

If height was provided, you also get:

  • isOverflowing — whether the text exceeds the container
  • availableHeight — usable height after insets
  • overflowAmount — how many pixels the text exceeds the container by
  • maxLines — how many lines fit in the container
  • suggestedHeight — recommended container height to fit all the text

Examples

Basic Measurement with Overflow Check

slides_measure_text({
  measurements: [
    {
      text: "- Revenue up 18% QoQ\n- 340 new customers\n- Expanded to 3 new markets",
      fontSize: 16,
      width: 600,
      height: 200
    }
  ]
})

// Response:
// {
//   measurements: [
//     {
//       estimatedHeight: 84,
//       estimatedLines: 3,
//       availableWidth: 580,
//       isOverflowing: false,
//       availableHeight: 190
//     }
//   ]
// }

Detecting Overflow

When text doesn't fit, the response includes the overflow amount and a suggested height:

// Check if text fits in a small container
slides_measure_text({
  measurements: [
    {
      text: "This is a long paragraph that might not fit in a narrow container on the slide.",
      fontSize: 16,
      width: 200,
      height: 40
    }
  ]
})

// Response:
// {
//   measurements: [
//     {
//       estimatedHeight: 88,
//       estimatedLines: 4,
//       availableWidth: 180,
//       isOverflowing: true,
//       availableHeight: 30,
//       overflowAmount: 58,
//       maxLines: 1,
//       suggestedHeight: 98
//     }
//   ]
// }

Measuring Multiple Texts for Layout

Measure a title and body text together to calculate stacked positioning:

// Measure multiple texts to calculate a stacked layout
slides_measure_text({
  measurements: [
    {
      text: "Q4 Business Review",
      fontSize: 40,
      width: 600
    },
    {
      text: "- Revenue highlights\n- Key initiatives\n- Next steps\n- Timeline",
      fontSize: 16,
      width: 600,
      fontFamily: "Inter",
      lineSpacing: 1.2
    }
  ]
})

// Response:
// {
//   measurements: [
//     { estimatedHeight: 52, estimatedLines: 1, availableWidth: 580 },
//     { estimatedHeight: 108, estimatedLines: 4, availableWidth: 580 }
//   ]
// }
//
// Now the assistant knows: title needs ~52px, body needs ~108px
// It can position the body at y = titleY + 52 + gap

Measuring Text Inside Shapes

Circles and diamonds have less usable space than rectangles. Use shapeType to account for the inscribed text area:

// Measure text inside a circle (inscribed text area is smaller)
slides_measure_text({
  measurements: [
    {
      text: "85%",
      fontSize: 48,
      width: 200,
      height: 200,
      shapeType: "circle"
    }
  ]
})

Related

  • Element Operations — Create and style text and shape elements after measuring
  • Styling — Font sizes, text formatting, and design techniques
  • Fonts — Discover available fonts before measuring
  • Canvas Size — Slide dimensions for calculating element positions