feat(fonts): honor selected fonts in PDF export

Interpolate the book's body and heading families into the Typst
preamble, title page, cover, and contents. Embed the needed bundled
fonts and load any chosen system fonts (via fontdb) into the Typst
engine so PDF preview and export match the on-screen fonts.
This commit is contained in:
pj committed 2026-06-22 14:27:51 -04:00
1 parent 9a38976000
commit 7a2d7c6aff
5 files changed
+93 -21

No files matched your search

+13 -1
View File
@@ -7,12 +7,24 @@ export interface ImageInput {
data: string;
}
export interface PdfFonts {
bundled: string[];
system: string[];
}
export async function compilePdf(
source: string,
images: ImageInput[] = [],
emitWarnings = false,
fonts: PdfFonts = { bundled: [], system: [] },
): Promise<Uint8Array> {
const buffer = await invoke<ArrayBuffer>("compile_pdf", { source, images, emitWarnings });
const buffer = await invoke<ArrayBuffer>("compile_pdf", {
source,
images,
emitWarnings,
bundledFonts: fonts.bundled,
systemFonts: fonts.system,
});
return new Uint8Array(buffer);
}