Skip to content

feat: add fontFamily, letterSpacing and lineHeight to text tools - #139

Open
kuba-guzik wants to merge 1 commit into
grab:mainfrom
kuba-guzik:feat/font-family-support
Open

feat: add fontFamily, letterSpacing and lineHeight to text tools#139
kuba-guzik wants to merge 1 commit into
grab:mainfrom
kuba-guzik:feat/font-family-support

Conversation

@kuba-guzik

Copy link
Copy Markdown

Summary

Adds a fontFamily parameter to the create_text and set_text_content tools, allowing users to specify custom font families when creating or modifying text nodes in Figma.

Changes

  • create_text (server.ts + code.js): Added optional fontFamily parameter (defaults to "Inter"). The Figma plugin attempts to load the requested font family and falls back to Inter if it's not available.
  • set_text_content (server.ts + code.js): Added optional fontFamily and fontWeight parameters for changing the font of existing text nodes. If not provided, the existing font is preserved.
  • TypeScript types: Updated the FigmaCommand type to include the new optional fields.

Motivation

Currently, all text created via create_text uses hardcoded "Inter" font family. This prevents users from building design systems that use custom fonts (e.g., brand typography like "Arbeit Pro", "Roboto", etc.).

Addresses #138.

API

// create_text - new optional parameter
fontFamily?: string  // e.g., "Roboto", "Arbeit Pro Trial" (default: "Inter")

// set_text_content - new optional parameters
fontFamily?: string  // change font family of existing text
fontWeight?: number  // change font weight of existing text

Fallback behavior

If the requested font is not available in Figma (not installed locally or not in the document), the plugin:

  1. Logs a warning to the console
  2. Falls back to "Inter" (for create_text) or keeps the existing font (for set_text_content)

This ensures backward compatibility — existing usage without fontFamily continues to work exactly as before.

Test plan

  • Create text with default font (no fontFamily) — should use Inter as before
  • Create text with fontFamily: "Roboto" — should use Roboto if available
  • Create text with unavailable font — should fall back to Inter with console warning
  • Use set_text_content with fontFamily to change an existing node's font
  • Use set_text_content without fontFamily — should preserve existing font

Made with Cursor

Extends create_text and set_text_content with full typography control:
- fontFamily: custom font support with Inter fallback
- letterSpacing: precise tracking in pixels
- lineHeight: explicit line height in pixels

All params are optional and backward-compatible. Addresses grab#138.

Co-authored-by: Cursor <cursoragent@cursor.com>
@kuba-guzik
kuba-guzik force-pushed the feat/font-family-support branch from a60f526 to 175c119 Compare February 16, 2026 15:47
@kuba-guzik kuba-guzik changed the title feat: add fontFamily parameter to create_text and set_text_content feat: add fontFamily, letterSpacing and lineHeight to text tools Feb 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant