refactor changes

This commit is contained in:
pj committed 2026-08-30 16:58:02 +05:30
1 parent c1c47bc513
commit f7a536b2c3
58 files changed
+2524 -320

No files matched your search

+15 -2
View File
@@ -1,13 +1,26 @@
// PDF export. The source is built here and compiled there; these two calls are the boundary.
import { call, type ImageInput } from "../ipc";
import { fontsUsed, type DocumentFonts } from "../model/fonts";
/**
* Compiles Typst source to PDF bytes. Warnings do not come back through the return value, because
* the answer is raw bytes and has no room for a second one: they arrive on `pdf-warnings` instead.
*
* `fonts` is the document's own pair, and what crosses the boundary is which faces to load rather
* than their bytes: a bundled id the backend already has compiled in, a system family name it can
* look up. The source names the families itself, so this only has to make sure the compiler can
* see them.
*/
export const pdfCompile = (source: string, images: readonly ImageInput[]) =>
call<ArrayBuffer>("pdf_compile", { source, images });
export const pdfCompile = (source: string, images: readonly ImageInput[], fonts: DocumentFonts) => {
const used = fontsUsed(fonts);
return call<ArrayBuffer>("pdf_compile", {
source,
images,
bundledFonts: used.bundled,
systemFonts: used.system,
});
};
/**
* Writes the finished file wherever the native save panel pointed.