docs/contributing/frontend/canvas-text-tool.md
The canvas text workflow is split between a Konva module that owns tool state and a React overlay that handles text entry.
invokeai/frontend/web/src/features/controlLayers/konva/CanvasTool/CanvasTextToolModule.ts
invokeai/frontend/web/src/features/controlLayers/components/Text/CanvasTextOverlay.tsx
contentEditable overlay positioned in canvas space.invokeai/frontend/web/src/features/controlLayers/components/Text/TextToolOptions.tsx
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:
calculateLayerPosition() calculates the top-left position for the raster layer after applying the configured padding and alignment offsets.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:
TEXT_FONT_STACKS with the new id, label, and CSS font-family stack.TEXT_FONT_IDS tuple and update the canvasTextSlice schema default (TEXT_DEFAULT_FONT_ID).public/locales/*.getFontStackById().