# measuring-text

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.

- rule · `type=rule` · Claude Code, Codex, Cursor, GitHub Copilot, Windsurf (Devin Desktop), Cline · ★ 849 repo stars
- Author: coleam00
- License: not stated · policy=link-only · description only; the file stays with the author
- Source: https://github.com/coleam00/second-brain-skills/tree/HEAD/.claude/skills/remotion/rules/measuring-text.md
- Updated: 2026-01-24
- Security check: automated, 2026-11-16 (text) — no signs of malicious code found.
- HTML: https://affpapa.org/en/nevibecode/rules/measuring-text

## What it 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.

## Install

### Claude Code (native platform)

**Manually: put the files in place**
- File: `.claude/rules/measuring-text.md` — The paths frontmatter field limits the files

### Codex

**AGENTS.md**
- Codex reads AGENTS.md: paste the rule text there

### Cursor

**Manually: put the files in place**
- File: `.cursor/rules/measuring-text.mdc` — Frontmatter: description, globs, alwaysApply

### GitHub Copilot

**Manually: put the files in place**
- File: `.github/instructions/measuring-text.instructions.md` — The applyTo field sets which files it applies to

### Windsurf (Devin Desktop)

**Manually: put the files in place**
- File: `.devin/rules/measuring-text.md`

### Cline

**Manually: put the files in place**
- File: `.clinerules/measuring-text.md`

Where a file is given instead of a command, copy the files from the source to that path: https://github.com/coleam00/second-brain-skills/tree/HEAD/.claude/skills/remotion/rules/measuring-text.md

## When to use it
- 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
- 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

## Similar
- [3d-text-depth-layers](https://affpapa.org/en/nevibecode/rules/3d-text-depth-layers.md) — rule · ★ 78316 repo stars
- [pretext-text-measurement](https://affpapa.org/en/nevibecode/skills/pretext-text-measurement.md) — skill · 701 installs
- [animate-text](https://affpapa.org/en/nevibecode/skills/animate-text.md) — skill · 2800 installs
- [humanize-text](https://affpapa.org/en/nevibecode/skills/humanize-text.md) — skill · 214 installs
- [site-specification](https://affpapa.org/en/nevibecode/skills/site-specification.md) — skill · 2600 installs
- [agency-grid-layout-minimal](https://affpapa.org/en/nevibecode/skills/agency-grid-layout-minimal.md) — skill · 1800 installs

From the same set: [coleam00/second-brain-skills](https://affpapa.org/en/nevibecode/by/coleam00/second-brain-skills.md) — 33 cards

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
