fix: 内置DOCX双中文字体包
This commit is contained in:
@@ -41,6 +41,11 @@ module.exports = {
|
||||
to: "samples",
|
||||
filter: ["**/*"]
|
||||
},
|
||||
{
|
||||
from: "../../output/font-packs/root",
|
||||
to: "font-packs",
|
||||
filter: ["**/*"]
|
||||
},
|
||||
{
|
||||
from: `.runtime/pandoc/${pandocRuntime.version}/windows-x86_64`,
|
||||
to: `pandoc/${pandocRuntime.version}/windows-x86_64`,
|
||||
|
||||
@@ -130,7 +130,7 @@ function getDesktopThemeDirectory() {
|
||||
: path.resolve(currentDirectory, "../../..", ".local", "themes");
|
||||
}
|
||||
|
||||
function getDesktopFontPackDirectory() {
|
||||
function getDesktopUserFontPackDirectory() {
|
||||
if (!app.isPackaged) {
|
||||
return path.resolve(
|
||||
currentDirectory,
|
||||
@@ -147,6 +147,15 @@ function getDesktopFontPackDirectory() {
|
||||
|
||||
function createDesktopApplicationService() {
|
||||
const projectRoot = path.resolve(currentDirectory, "../../..");
|
||||
const fontPackRoots = app.isPackaged
|
||||
? [
|
||||
path.join(process.resourcesPath, "font-packs"),
|
||||
getDesktopUserFontPackDirectory()
|
||||
]
|
||||
: [
|
||||
path.join(projectRoot, "output", "font-packs", "root"),
|
||||
getDesktopUserFontPackDirectory()
|
||||
];
|
||||
return createApplicationService({
|
||||
bundledRoot: app.isPackaged
|
||||
? path.join(process.resourcesPath, "themes")
|
||||
@@ -155,7 +164,7 @@ function createDesktopApplicationService() {
|
||||
createAssetUrl: (themeId, assetPath) =>
|
||||
`${APP_SCHEME}://${THEME_HOST}/${encodeURIComponent(themeId)}/${encodeThemeAssetPath(assetPath)}`,
|
||||
fontPacks: {
|
||||
roots: [getDesktopFontPackDirectory()],
|
||||
roots: fontPackRoots,
|
||||
appVersion: app.getVersion(),
|
||||
createAssetUrl: (
|
||||
packId,
|
||||
|
||||
@@ -72,7 +72,7 @@ describe("桌面发行构建链", () => {
|
||||
"npm run prepare:pandoc"
|
||||
);
|
||||
expect(rootManifest.scripts?.["desktop:package"]).toBe(
|
||||
"npm run package -w @md-to-pdf/desktop"
|
||||
"npm run build:font-pack && npm run package -w @md-to-pdf/desktop"
|
||||
);
|
||||
});
|
||||
|
||||
@@ -180,32 +180,28 @@ describe("桌面发行构建链", () => {
|
||||
);
|
||||
});
|
||||
|
||||
it("仅在组合构建时接入经过哈希校验的同目录字体包", () => {
|
||||
it("在安装版与便携版中强制内置完整字体包集合", () => {
|
||||
const builderConfig = readFileSync(
|
||||
`${desktopRoot}/electron-builder.config.cjs`,
|
||||
"utf8"
|
||||
);
|
||||
const installerInclude = readFileSync(
|
||||
`${desktopRoot}/build/installer.nsh`,
|
||||
const desktopMain = readFileSync(
|
||||
`${desktopRoot}/src/main.ts`,
|
||||
"utf8"
|
||||
);
|
||||
const companionBuild = readFileSync(
|
||||
const bundledBuild = readFileSync(
|
||||
`${projectRoot}/scripts/build-desktop-with-font-pack.mjs`,
|
||||
"utf8"
|
||||
);
|
||||
|
||||
expect(builderConfig).toContain("MD_TO_PDF_NSIS_INCLUDE");
|
||||
expect(installerInclude).toContain("FONT_PACK_COMPANION_SHA256");
|
||||
expect(installerInclude).toContain("StdUtils.HashFile");
|
||||
expect(installerInclude).toContain("/WITHFONTPACK=");
|
||||
expect(companionBuild).toContain("createDesktopCompanionInclude");
|
||||
expect(companionBuild).toContain("MD_TO_PDF_NSIS_INCLUDE");
|
||||
expect(companionBuild).toContain(
|
||||
"MorphDoc-FontPack-mdtp-serif-sc-1.0.0-x86_64-Setup.exe"
|
||||
);
|
||||
expect(companionBuild).toContain(
|
||||
"MorphDoc-FontPack-mdtp-serif-sc-1.0.0.zip"
|
||||
expect(builderConfig).toContain('../../output/font-packs/root');
|
||||
expect(builderConfig).toContain('to: "font-packs"');
|
||||
expect(desktopMain).toContain(
|
||||
'path.join(process.resourcesPath, "font-packs")'
|
||||
);
|
||||
expect(desktopMain).toContain("getDesktopUserFontPackDirectory()");
|
||||
expect(bundledBuild).not.toContain("createDesktopCompanionInclude");
|
||||
expect(bundledBuild).toContain("已生成内置字体包");
|
||||
});
|
||||
|
||||
it("将 DOCX Lua Filter 复制到桌面主进程资源目录", () => {
|
||||
|
||||
Reference in New Issue
Block a user