load_font_async
Load fonts asynchronously in Figma to ensure text elements display correctly without blocking the interface, specifying font family and optional style parameters.
Instructions
Load a font asynchronously in Figma
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| family | Yes | Font family name | |
| style | No | Font style (e.g., 'Regular', 'Bold', 'Italic') |
Implementation Reference
- The execution handler for the 'load_font_async' MCP tool. It sends a 'load_font_async' command to Figma via websocket, processes the result, and returns a formatted text response indicating success or error.async ({ family, style }) => { try { const result = await sendCommandToFigma("load_font_async", { family, style: style || "Regular" }); const typedResult = result as { success: boolean, family: string, style: string, message: string }; return { content: [ { type: "text", text: typedResult.message || `Loaded font ${family} ${style || "Regular"}` } ] }; } catch (error) { return { content: [ { type: "text", text: `Error loading font: ${error instanceof Error ? error.message : String(error)}` } ] }; } }
- Input schema for the 'load_font_async' tool using Zod validation: requires 'family' string, optional 'style' string.{ family: z.string().describe("Font family name"), style: z.string().optional().describe("Font style (e.g., 'Regular', 'Bold', 'Italic')"), },
- src/talk_to_figma_mcp/tools/text-tools.ts:497-530 (registration)Registration of the 'load_font_async' tool on the MCP server within the registerTextTools function, including name, description, input schema, and handler.server.tool( "load_font_async", "Load a font asynchronously in Figma", { family: z.string().describe("Font family name"), style: z.string().optional().describe("Font style (e.g., 'Regular', 'Bold', 'Italic')"), }, async ({ family, style }) => { try { const result = await sendCommandToFigma("load_font_async", { family, style: style || "Regular" }); const typedResult = result as { success: boolean, family: string, style: string, message: string }; return { content: [ { type: "text", text: typedResult.message || `Loaded font ${family} ${style || "Regular"}` } ] }; } catch (error) { return { content: [ { type: "text", text: `Error loading font: ${error instanceof Error ? error.message : String(error)}` } ] }; } } );