load_font_async
Load fonts asynchronously in Figma to ensure text elements display correctly with specified font families and styles during design workflows.
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
- src/talk_to_figma_mcp/tools/text-tools.ts:497-530 (registration)Registration of the 'load_font_async' MCP tool including name, description, input schema, and handler function.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)}` } ] }; } } );
- The handler function that executes the load_font_async tool logic by sending a command to the Figma plugin via websocket and formatting the response.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 validation for the load_font_async tool using Zod, defining 'family' (required string) and 'style' (optional 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/index.ts:12-19 (registration)Higher-level registration that calls registerTextTools(server), which includes load_font_async.export function registerTools(server: McpServer): void { // Register all tool categories registerDocumentTools(server); registerCreationTools(server); registerModificationTools(server); registerTextTools(server); registerComponentTools(server); }
- src/talk_to_figma_mcp/server.ts:34-34 (registration)Top-level MCP server setup that registers all tools, indirectly registering load_font_async.registerTools(server);