feat: 接入可选字体包同源渲染链
This commit is contained in:
@@ -11,6 +11,7 @@ import {
|
||||
import type { DocxFontSource } from "@md-to-pdf/docx-engine";
|
||||
import {
|
||||
createThemeRegistry,
|
||||
type ThemeFontPackStatus,
|
||||
type ThemeRegistryOptions
|
||||
} from "./theme-registry.js";
|
||||
import {
|
||||
@@ -50,6 +51,7 @@ export interface PreparedDocxExport {
|
||||
source: "bundled" | "local";
|
||||
css: string;
|
||||
fonts: DocxFontSource[];
|
||||
fontPack?: ThemeFontPackStatus;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -188,10 +190,11 @@ export function createApplicationService(
|
||||
);
|
||||
}
|
||||
|
||||
const [document, themeCss, themeFonts] = await Promise.all([
|
||||
const [document, themeCss, themeFonts, fontPack] = await Promise.all([
|
||||
render(parsed.data, context),
|
||||
themes.getCss(theme.manifest.id),
|
||||
themes.getDocxFonts(theme.manifest.id)
|
||||
themes.getDocxFonts(theme.manifest.id),
|
||||
themes.getFontPackStatus(theme.manifest.id)
|
||||
]);
|
||||
if (themeCss === undefined || themeFonts === undefined) {
|
||||
throw new ApplicationRequestError(
|
||||
@@ -208,7 +211,8 @@ export function createApplicationService(
|
||||
manifest: theme.manifest,
|
||||
source: theme.source,
|
||||
css: themeCss,
|
||||
fonts: themeFonts
|
||||
fonts: themeFonts,
|
||||
...(fontPack ? { fontPack } : {})
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -216,6 +220,7 @@ export function createApplicationService(
|
||||
return {
|
||||
getThemeAsset: themes.getAsset,
|
||||
getThemeCss: themes.getCss,
|
||||
getFontPackAsset: themes.getFontPackAsset,
|
||||
invalidateThemes: themes.invalidate,
|
||||
listThemes,
|
||||
prepareDocxExport,
|
||||
|
||||
Reference in New Issue
Block a user