Canvas Text Tool | InvokeAI Documentation

Canvas Text Tool

Overview

The canvas text workflow is split between a Konva module that owns tool state and a React overlay that handles text entry.

Rasterization pipeline

renderTextToCanvas() (invokeai/frontend/web/src/features/controlLayers/text/textRenderer.ts) converts the editor contents into a transparent canvas. The Text tool module configures the renderer with the active font stack, weight, styling flags, alignment, and the active canvas color. The resulting canvas is encoded to a PNG data URL and stored in a new raster layer (image object) with a transparent background.

Layer placement preserves the original click location:

Font stacks

Font definitions live in invokeai/frontend/web/src/features/controlLayers/text/textConstants.ts as ten deterministic stacks (sans, serif, mono, rounded, script, humanist, slab serif, display, narrow, UI serif). Each stack lists system-safe fallbacks so the editor can choose the first available font per platform.

To add or adjust fonts:

  1. Update TEXT_FONT_STACKS with the new id, label, and CSS font-family stack.
  2. If you add a new stack, extend the TEXT_FONT_IDS tuple and update the canvasTextSlice schema default (TEXT_DEFAULT_FONT_ID).
  3. Provide translation strings for any new labels in public/locales/*.
  4. The editor and renderer will automatically pick up the new stack via getFontStackById().