Skip to main content
rule CX Codex

measuring-text — Claude Code rule: text dimensions in Remotion

measuring-text — a rule to calculate text size, fit fonts to containers, and detect overflow. Use it when building dynamic text in Remotion and need precise dimensions to avoid clipping or wrong scaling.

no license ★ 849 updated 2026-01-24

Install into Claude Code · Manually: put the files in place All methods and platforms ↓
.claude/rules/measuring-text.md
Open on GitHub

What measuring-text does

The rule brings @remotion/layout-utils functions into your Claude Code workflow: measureText() computes text width and height for a given font and size, fitText() finds the right font size to fit text within a width limit, fillTextBox() tracks whether text exceeds a box as you add words line by line.

Three examples cover the main scenarios: measuring a single string, scaling text to fit a container with a maximum size, and adding words one at a time while checking for overflow. Measurement results are cached, so repeated calls are fast.

Fonts must be loaded before measuring—otherwise results won't match the rendered output. The rule shows how to load fonts from Google Fonts and enable validation with validateFontIsLoaded. Font properties like size, weight, and letter spacing must stay consistent between measurement and render, or numbers and visuals will diverge.

What it helps with

  • calculate text dimensions with a specific font and weight
  • find the right font size to fit text in a fixed width
  • check if text exceeds a box by width or line count
  • build text line by line and stop before overflow

Example prompts for the agent

  • Get the height of the text 'Final frame' in Arial 24
  • Fit a product description into 500 pixels wide by picking the best font size
  • Verify that 3 lines of copy fit in a 400×600 box at size 18

How to install measuring-text

Manually: put the files in place

.claude/rules/measuring-text.md

The paths frontmatter field limits the files

Step by step, with commands for each platform: AGENTS.md vs CLAUDE.md: what they are and which one to use

Questions about measuring-text

How do I install measuring-text in Claude Code?

Copy the rule content to .claude/rules/measuring-text.md at your project root. For Cursor, use .cursor/rules/measuring-text.mdc. Other editors use their own paths—check the install docs.

What does this rule do?

It adds Remotion text measurement functions to Claude Code: measureText() gets text size, fitText() scales font to fit a width, fillTextBox() tracks overflow as you add text. Results cache for speed.

Why do I need to load fonts before measuring?

Font metrics change based on which font file is loaded. Measure before fonts load and your numbers won't match the rendered output. Use waitUntilDone() or validateFontIsLoaded: true to catch timing issues.

Similar IDE rules

All IDE rules for Frontend and UI →

From the same set33

The whole set →
parameters Explains how to add video parameterization using Zod schemas in Remotion compositions. Lets users edit parameters visually in the sidebar instead of hardcoding them. CX Codex +1 ★ 849repo stars sequencing sequencing — a rule for managing component timing in Remotion videos. Uses Sequence for delays and Series for sequential playback, with support for nested and overlapping scenes. CX Codex +1 ★ 849repo stars images images directs the AI to embed graphics in Remotion via the Img element, staticFile helper, and dimensions calculation. CX Codex +1 ★ 849repo stars calculate-metadata The calculate-metadata rule configures Remotion composition metadata before rendering, including duration, dimensions, FPS, props, and the output filename. CX Codex +1 ★ 849repo stars fonts Guides Claude Code on loading Google Fonts and local font assets in Remotion video projects without render glitches. CX Codex +1 ★ 849repo stars videos videos — a rule for embedding video in Remotion compositions with trimming, volume control, playback speed, looping and pitch adjustment. Lets you work with video files in animations without repeating boilerplate code. CX Codex +1 ★ 849repo stars display-captions display-captions — a rule that walks through drawing captions in Remotion: grouping them into TikTok-style pages and highlighting whichever word is being spoken. CX Codex +1 ★ 849repo stars compositions Sets guidelines for structuring Remotion compositions, still frames, folders, and dynamic metadata in src/Root.tsx. CX Codex +1 ★ 849repo stars

Project sponsors

Companies that keep this analytics open