diff --git a/packages/core/src/rpc/read-commands.ts b/packages/core/src/rpc/read-commands.ts index df9d6599c..23478e195 100644 --- a/packages/core/src/rpc/read-commands.ts +++ b/packages/core/src/rpc/read-commands.ts @@ -1,6 +1,6 @@ import type { SceneGraph, SceneNode } from '@open-pencil/scene-graph' -import { documentFontStatus, type DocumentFontStatus } from '#core/text/font/status' +import { prepareGraphFonts } from '#core/text/prepare' import { queryByXPath } from '#core/xpath' import type { RPCCommand } from './types' @@ -79,7 +79,10 @@ export const infoCommand: RPCCommand = { export const fontStatusCommand: RPCCommand = { name: 'font-status', - execute: (graph) => documentFontStatus(graph, graph.getPages()[0]?.id ?? graph.rootId) + execute: async (graph) => { + const pageId = graph.getPages()[0]?.id ?? graph.rootId + return prepareGraphFonts(graph, pageId, [pageId]) + } } // ── pages ── diff --git a/tests/engine/cli/fonts.test.ts b/tests/engine/cli/fonts.test.ts index 6295370e4..f59139882 100644 --- a/tests/engine/cli/fonts.test.ts +++ b/tests/engine/cli/fonts.test.ts @@ -4,6 +4,7 @@ import { tmpdir } from 'node:os' import { join } from 'node:path' import { BUILTIN_IO_FORMATS, IORegistry } from '@open-pencil/core/io' +import type { DocumentFontStatus } from '@open-pencil/core/text' import { runOpenPencilCLI } from '#tests/helpers/cli' import { repoPath, requireBuiltWorkspacePackages } from '#tests/helpers/paths' @@ -34,9 +35,9 @@ test('reports bundled fonts as available', async () => { const { stdout, stderr, exitCode } = await runOpenPencilCLI(['fonts', GOLD, '--json']) expect(stderr).toBe('') expect(exitCode).toBe(0) - const data = JSON.parse(stdout) + const data: DocumentFontStatus = JSON.parse(stdout) expect(data.faithful).toBe(true) - expect(data.faces.every((face: { source: string }) => face.source === 'bundled')).toBe(true) + expect(data.faces.every((face) => face.source === 'bundled')).toBe(true) }) heavy('fonts CLI', () => { @@ -45,10 +46,10 @@ heavy('fonts CLI', () => { const { stdout, stderr, exitCode } = await runOpenPencilCLI(['fonts', fixture, '--json']) expect(stderr).toBe('') expect(exitCode).toBe(0) - const data = JSON.parse(stdout) + const data: DocumentFontStatus = JSON.parse(stdout) expect(data.faithful).toBe(false) expect(data.issues.length).toBeGreaterThan(0) - expect(data.issues.every((face: { status: string }) => face.status === 'unresolved')).toBe(true) + expect(data.issues.every((face) => face.status === 'unresolved')).toBe(true) }) test('uses the standard human-readable formatter', async () => { const { stdout, stderr, exitCode } = await runOpenPencilCLI(['fonts', GOLD])