Skip to content

Commit 9cd8230

Browse files
committed
Update
1 parent c35e158 commit 9cd8230

File tree

3 files changed

+31
-31
lines changed

3 files changed

+31
-31
lines changed

images/exporter-build/scripts/processor.py

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -100,30 +100,38 @@ def ensure_parity(self, target_parity):
100100
return True
101101
return False
102102

103-
def draw_decorations(self, doc, start_page_num, book_title, section_title):
104-
font_name = "china-ss"
103+
def draw_decorations(self, doc, start_page_num, book_title, section_title, sub_title):
104+
font_name = "china-sr" # 使用宋体/衬线体匹配 Noto Serif
105105
for i in range(len(doc)):
106106
page = doc[i]
107107
abs_page = start_page_num + i
108108
if abs_page in self.skip_decoration_pages:
109109
continue
110+
110111
is_odd = abs_page % 2 != 0
111112
footer_font = "helv"
112113
footer_size = 9
113114
footer_y = page.rect.height - 30
114115
footer_text = f"{abs_page}"
116+
117+
# 页脚:始终居中
115118
page.insert_text((page.rect.width / 2 - 5, footer_y), footer_text, fontsize=footer_size, fontname=footer_font, color=(0.4, 0.4, 0.4))
119+
116120
header_y = 35
117121
line_y = 45
118122
header_size = 9
119123
color = (0.5, 0.5, 0.5)
124+
120125
if is_odd:
126+
# 奇数页:页眉在左上,内容为章节标题 (L1)
121127
text = section_title
128+
page.insert_text((40, header_y), text, fontsize=header_size, fontname=font_name, color=color)
129+
else:
130+
# 偶数页:页眉在右上,内容为小节标题 (L2)
131+
text = sub_title
122132
tw = fitz.get_text_length(text, fontname=font_name, fontsize=header_size)
123133
page.insert_text((page.rect.width - tw - 40, header_y), text, fontsize=header_size, fontname=font_name, color=color)
124-
else:
125-
text = book_title
126-
page.insert_text((40, header_y), text, fontsize=header_size, fontname=font_name, color=color)
134+
127135
page.draw_line((40, line_y), (page.rect.width - 40, line_y), color=(0.8, 0.8, 0.8), width=0.4)
128136

129137
def get_english_filename(self):
@@ -217,7 +225,7 @@ def process(self):
217225
else:
218226
self.toc_data.append([2, sub_title, self.page_offset + 1])
219227
self.toc_data.extend(chapter_headings)
220-
self.draw_decorations(doc, self.page_offset + 1, book_title, sec_title)
228+
self.draw_decorations(doc, self.page_offset + 1, book_title, sec_title, sub_title)
221229
self.final_doc.insert_pdf(doc)
222230
self.page_offset += len(doc)
223231
doc.close()

images/exporter-build/templates/cover.tex.j2

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
\documentclass[12pt,a4paper]{article}
2-
\usepackage[utf8]{inputenc}
32
\usepackage{fontspec}
43
\usepackage{geometry}
54
\geometry{a4paper, margin=1in}

images/exporter-build/templates/frontispiece.tex.j2

Lines changed: 17 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -9,31 +9,24 @@
99

1010
\begin{document}
1111
\thispagestyle{empty}
12-
\vspace*{3cm}
12+
\vspace*{2cm}
13+
1314
\begin{center}
14-
{\Huge \bfseries {{ title }}} \par
15-
\vspace{0.8cm}
16-
{\huge \itshape \color{graycolor} {{ subtitle }}} \par
17-
\vspace{3cm}
18-
{\large 作者:{{ authors | join(', ') }}} \par
19-
20-
\vfill
21-
22-
\begin{minipage}{0.8\textwidth}
23-
\centering
24-
{\Large \textbf{丛书简介}} \par \vspace{1cm}
25-
{\large \setlength{\parindent}{2em}
26-
{% for line in info.abstract %}
27-
{{ line }} \par \vspace{0.4cm}
28-
{% endfor %}
29-
}
30-
\end{minipage}
31-
32-
\vfill
33-
34-
{\large {{ info.publishing }}} \par
35-
\vspace{0.5cm}
36-
{\large {{ info.date or "\today" }}}
15+
{\Large \textbf{从书简介}} \par \vspace{1.5cm}
3716
\end{center}
17+
18+
{\large
19+
{% for line in info.abstract %}
20+
{{ line }} \par \vspace{0.6cm}
21+
{% endfor %}
22+
}
23+
24+
\vfill
25+
26+
\begin{center}
27+
{\large {{ info.publishing }}}
28+
\end{center}
29+
\vspace*{0.5cm} % 留出底边距,对齐封面的日期高度
30+
3831
\newpage
3932
\end{document}

0 commit comments

Comments
 (0)