From 6ec5e1404f2a9ade5bebfd36b6c874339d75d695 Mon Sep 17 00:00:00 2001 From: ":NoBody:" Date: Sat, 13 Jun 2026 19:49:26 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E4=BA=86=E7=9B=AE=E5=BD=95?= =?UTF-8?q?=E7=BB=93=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../computer_template/build.js | 0 .../computer_template/cover_page.html | 0 .../computer_template/end_page.html | 0 .../computer_template/fonts.html | 27 ++++++++++--------- .../computer_template/style.html | 0 .../gp => templates}/mobile_template/build.js | 0 .../mobile_template/cover_page.html | 0 .../mobile_template/end_page.html | 0 .../mobile_template/fonts.html | 27 ++++++++++--------- .../mobile_template/style.html | 0 .../printable_template/build.js | 0 .../printable_template/cover_page.html | 0 .../printable_template/end_page.html | 0 .../printable_template/fonts.html | 27 ++++++++++--------- .../printable_template/style.html | 0 tools/gp/config.json | 8 +++--- tools/gp/pdf_builder/index_builder.ts | 17 +++++++++--- 17 files changed, 60 insertions(+), 46 deletions(-) rename {tools/gp => templates}/computer_template/build.js (100%) rename {tools/gp => templates}/computer_template/cover_page.html (100%) rename {tools/gp => templates}/computer_template/end_page.html (100%) rename {tools/gp => templates}/computer_template/fonts.html (91%) rename {tools/gp => templates}/computer_template/style.html (100%) rename {tools/gp => templates}/mobile_template/build.js (100%) rename {tools/gp => templates}/mobile_template/cover_page.html (100%) rename {tools/gp => templates}/mobile_template/end_page.html (100%) rename {tools/gp => templates}/mobile_template/fonts.html (91%) rename {tools/gp => templates}/mobile_template/style.html (100%) rename {tools/gp => templates}/printable_template/build.js (100%) rename {tools/gp => templates}/printable_template/cover_page.html (100%) rename {tools/gp => templates}/printable_template/end_page.html (100%) rename {tools/gp => templates}/printable_template/fonts.html (91%) rename {tools/gp => templates}/printable_template/style.html (100%) diff --git a/tools/gp/computer_template/build.js b/templates/computer_template/build.js similarity index 100% rename from tools/gp/computer_template/build.js rename to templates/computer_template/build.js diff --git a/tools/gp/computer_template/cover_page.html b/templates/computer_template/cover_page.html similarity index 100% rename from tools/gp/computer_template/cover_page.html rename to templates/computer_template/cover_page.html diff --git a/tools/gp/computer_template/end_page.html b/templates/computer_template/end_page.html similarity index 100% rename from tools/gp/computer_template/end_page.html rename to templates/computer_template/end_page.html diff --git a/tools/gp/computer_template/fonts.html b/templates/computer_template/fonts.html similarity index 91% rename from tools/gp/computer_template/fonts.html rename to templates/computer_template/fonts.html index 6cae36b..cd70614 100644 --- a/tools/gp/computer_template/fonts.html +++ b/templates/computer_template/fonts.html @@ -1,52 +1,53 @@ diff --git a/tools/gp/computer_template/style.html b/templates/computer_template/style.html similarity index 100% rename from tools/gp/computer_template/style.html rename to templates/computer_template/style.html diff --git a/tools/gp/mobile_template/build.js b/templates/mobile_template/build.js similarity index 100% rename from tools/gp/mobile_template/build.js rename to templates/mobile_template/build.js diff --git a/tools/gp/mobile_template/cover_page.html b/templates/mobile_template/cover_page.html similarity index 100% rename from tools/gp/mobile_template/cover_page.html rename to templates/mobile_template/cover_page.html diff --git a/tools/gp/mobile_template/end_page.html b/templates/mobile_template/end_page.html similarity index 100% rename from tools/gp/mobile_template/end_page.html rename to templates/mobile_template/end_page.html diff --git a/tools/gp/mobile_template/fonts.html b/templates/mobile_template/fonts.html similarity index 91% rename from tools/gp/mobile_template/fonts.html rename to templates/mobile_template/fonts.html index 6cae36b..cd70614 100644 --- a/tools/gp/mobile_template/fonts.html +++ b/templates/mobile_template/fonts.html @@ -1,52 +1,53 @@ diff --git a/tools/gp/mobile_template/style.html b/templates/mobile_template/style.html similarity index 100% rename from tools/gp/mobile_template/style.html rename to templates/mobile_template/style.html diff --git a/tools/gp/printable_template/build.js b/templates/printable_template/build.js similarity index 100% rename from tools/gp/printable_template/build.js rename to templates/printable_template/build.js diff --git a/tools/gp/printable_template/cover_page.html b/templates/printable_template/cover_page.html similarity index 100% rename from tools/gp/printable_template/cover_page.html rename to templates/printable_template/cover_page.html diff --git a/tools/gp/printable_template/end_page.html b/templates/printable_template/end_page.html similarity index 100% rename from tools/gp/printable_template/end_page.html rename to templates/printable_template/end_page.html diff --git a/tools/gp/printable_template/fonts.html b/templates/printable_template/fonts.html similarity index 91% rename from tools/gp/printable_template/fonts.html rename to templates/printable_template/fonts.html index 6cae36b..cd70614 100644 --- a/tools/gp/printable_template/fonts.html +++ b/templates/printable_template/fonts.html @@ -1,52 +1,53 @@ diff --git a/tools/gp/printable_template/style.html b/templates/printable_template/style.html similarity index 100% rename from tools/gp/printable_template/style.html rename to templates/printable_template/style.html diff --git a/tools/gp/config.json b/tools/gp/config.json index 9844d85..a6a4db7 100644 --- a/tools/gp/config.json +++ b/tools/gp/config.json @@ -5,7 +5,7 @@ "from_directory": "../../publications/25.5.0", "build_js_script": false, "build_mode": "detached", - "template_directory": "./mobile_template", + "template_directory": "../../templates/mobile_template", "folder_mode": "flat" }, "pdf": { @@ -42,7 +42,7 @@ "from_directory": "../../publications/25.5.0", "build_js_script": false, "build_mode": "detached", - "template_directory": "./computer_template", + "template_directory": "../../templates/computer_template", "folder_mode": "flat" }, "pdf": { @@ -79,9 +79,9 @@ "journal": { "from_directory": "../../publications/25.5.0", "build_mode": "detached", - "template_directory": "./printable_template", + "template_directory": "../../templates/printable_template", "folder_mode": "flat", - "build_js_script": "./printable_template/build.js" + "build_js_script": "../../templates/printable_template/build.js" }, "pdf": { "generate_index": true, diff --git a/tools/gp/pdf_builder/index_builder.ts b/tools/gp/pdf_builder/index_builder.ts index d180c8a..4fee897 100644 --- a/tools/gp/pdf_builder/index_builder.ts +++ b/tools/gp/pdf_builder/index_builder.ts @@ -17,6 +17,7 @@ type IndexItemLayout = { top: number; width: number; height: number; + fontSize: number; }; const PDF_PAGE_HEIGHT_PT = 842; @@ -255,6 +256,12 @@ export class IndexBuilder { const titleEl = item.querySelector("page_title") as any; const itemRect = item.getBoundingClientRect(); const titleRect = titleEl?.getBoundingClientRect() ?? itemRect; + const computedStyle = titleEl + ? globalThis.getComputedStyle(titleEl) + : null; + const fontSizePx = computedStyle + ? Number.parseFloat(computedStyle.fontSize || "0") + : 0; const pageIndex = Math.floor( (itemRect.bottom - 1) / printableHeightPx, ); @@ -263,8 +270,9 @@ export class IndexBuilder { pageIndex, left: titleRect.left, width: titleRect.width, - top: itemRect.top - pageTopPx, - height: itemRect.height, + top: titleRect.top - pageTopPx, + height: titleRect.height, + fontSize: fontSizePx, }; }); }, @@ -391,6 +399,7 @@ export class IndexBuilder { left: number; width: number; height: number; + fontSize: number; }>, inserted_index_pages: number, insert_index_after_page: number, @@ -425,6 +434,7 @@ export class IndexBuilder { const layoutLeftPt = layout.left * CSS_PX_TO_PT; const layoutWidthPt = layout.width * CSS_PX_TO_PT; const layoutHeightPt = layout.height * CSS_PX_TO_PT; + const fontSizePt = layout.fontSize * CSS_PX_TO_PT; const xLeft = Math.max(layoutLeftPt, 0); const xRight = Math.min(layoutLeftPt + layoutWidthPt, pageWidth); const mappedPage = this.remap_page_after_index_insert( @@ -448,7 +458,8 @@ export class IndexBuilder { return; } const localTopPt = layout.top * CSS_PX_TO_PT; - const yTop = pageHeight - marginTop - localTopPt; + const topOffsetPt = layout.pageIndex > 0 ? fontSizePt * 0.5 : 0; + const yTop = pageHeight - marginTop - localTopPt - topOffsetPt; const yBottom = yTop - totalHeight; this.add_link_annotation( targetPage as any,