odforge 0.3.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- odforge/__init__.py +1 -0
- odforge/benchmark.py +287 -0
- odforge/check.py +416 -0
- odforge/cli.py +1027 -0
- odforge/components.py +270 -0
- odforge/critic.py +1260 -0
- odforge/docfonts.py +104 -0
- odforge/editor_api.py +33 -0
- odforge/editor_launch.py +134 -0
- odforge/editor_routes.py +131 -0
- odforge/extract.py +478 -0
- odforge/feedback.py +86 -0
- odforge/fontembed.py +166 -0
- odforge/ir.py +1181 -0
- odforge/layoutcheck.py +602 -0
- odforge/llm.py +1865 -0
- odforge/localguard.py +42 -0
- odforge/mcp_server.py +552 -0
- odforge/media.py +352 -0
- odforge/odpedit.py +1219 -0
- odforge/package.py +114 -0
- odforge/pagefacts.py +388 -0
- odforge/preview.py +104 -0
- odforge/references.py +153 -0
- odforge/render/__init__.py +40 -0
- odforge/render/odp.py +5687 -0
- odforge/render/ods.py +155 -0
- odforge/render/odt.py +223 -0
- odforge/scene.py +657 -0
- odforge/setup_agents.py +274 -0
- odforge/skills/odforge-design/SKILL.md +298 -0
- odforge/skills/odforge-design/themes/academic.md +52 -0
- odforge/skills/odforge-design/themes/clay.md +53 -0
- odforge/skills/odforge-design/themes/color-system.md +59 -0
- odforge/skills/odforge-design/themes/crimson.md +53 -0
- odforge/skills/odforge-design/themes/dark.md +53 -0
- odforge/skills/odforge-design/themes/forest.md +54 -0
- odforge/skills/odforge-design/themes/gold.md +53 -0
- odforge/skills/odforge-design/themes/minimal.md +53 -0
- odforge/skills/odforge-design/themes/navy.md +56 -0
- odforge/skills/odforge-design/themes/plum.md +53 -0
- odforge/skills/odforge-design/themes/sky.md +53 -0
- odforge/skills/odforge-design/themes/slate.md +53 -0
- odforge/skills/odforge-design/themes/teal.md +53 -0
- odforge/skills/odforge-design/themes/violet.md +56 -0
- odforge/templates.py +250 -0
- odforge/textmetrics.py +616 -0
- odforge/textutil.py +24 -0
- odforge/themes.py +886 -0
- odforge/validate.py +403 -0
- odforge/watch.py +266 -0
- odforge/webapi.py +2617 -0
- odforge/webui/assets/editor-CjpYXM1a.css +1 -0
- odforge/webui/assets/editor-DPToJGio.js +3 -0
- odforge/webui/assets/jsx-runtime-C7KMcVI_.js +8 -0
- odforge/webui/assets/main-BLOs7Hnk.js +7 -0
- odforge/webui/assets/main-D21yFVE6.css +1 -0
- odforge/webui/editor.html +14 -0
- odforge/webui/index.html +25 -0
- odforge/xmlsafe.py +46 -0
- odforge/zipguard.py +91 -0
- odforge-0.3.0.dist-info/METADATA +95 -0
- odforge-0.3.0.dist-info/RECORD +66 -0
- odforge-0.3.0.dist-info/WHEEL +4 -0
- odforge-0.3.0.dist-info/entry_points.txt +3 -0
- odforge-0.3.0.dist-info/licenses/LICENSE +21 -0
odforge/themes.py
ADDED
|
@@ -0,0 +1,886 @@
|
|
|
1
|
+
"""ODForge presentation theme and layout data.
|
|
2
|
+
|
|
3
|
+
Pure-data module for the ``.odp`` renderer. Defines the slide page geometry,
|
|
4
|
+
the per-layout text frames, and the resolved design tokens (:class:`Theme`).
|
|
5
|
+
Contains no rendering logic; the only IR dependency is :class:`Presentation`
|
|
6
|
+
(imported lazily inside :func:`resolve_design` to keep this a pure-data module).
|
|
7
|
+
|
|
8
|
+
Page size is 16:9 = 28cm x 15.75cm. Positions and sizes are in centimetres;
|
|
9
|
+
font sizes are in points.
|
|
10
|
+
|
|
11
|
+
A :class:`Theme` is the *only* visual vocabulary the renderer understands: a
|
|
12
|
+
fully-resolved bundle of colour + typography tokens. It is produced either from
|
|
13
|
+
a built-in preset (:data:`THEMES`) or from a validated per-deck
|
|
14
|
+
:class:`~odforge.ir.DesignSpec` via :func:`resolve_design`.
|
|
15
|
+
"""
|
|
16
|
+
|
|
17
|
+
from __future__ import annotations
|
|
18
|
+
|
|
19
|
+
from dataclasses import dataclass, replace
|
|
20
|
+
from typing import TYPE_CHECKING
|
|
21
|
+
|
|
22
|
+
if TYPE_CHECKING: # pragma: no cover - typing only
|
|
23
|
+
from odforge.ir import Presentation
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
@dataclass(frozen=True)
|
|
27
|
+
class Frame:
|
|
28
|
+
role: str # "title" | "subtitle" | "bullets" | "left" | "right" | "fact"
|
|
29
|
+
x: float
|
|
30
|
+
y: float
|
|
31
|
+
w: float
|
|
32
|
+
h: float # cm
|
|
33
|
+
size_pt: int
|
|
34
|
+
bold: bool = False
|
|
35
|
+
center: bool = False
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
@dataclass(frozen=True)
|
|
39
|
+
class Theme:
|
|
40
|
+
"""Fully-resolved design tokens the renderer consumes.
|
|
41
|
+
|
|
42
|
+
Colours are ``#RRGGBB`` hex; ``*_pt`` sizes are points. ``title_color``
|
|
43
|
+
defaults conceptually to ``text`` but is stored explicitly so dark themes
|
|
44
|
+
can override it. The legacy ``text_color`` / ``font`` names the v1 ``.odp``
|
|
45
|
+
renderer reads are exposed as read-only aliases below.
|
|
46
|
+
"""
|
|
47
|
+
|
|
48
|
+
bg: str
|
|
49
|
+
surface: str
|
|
50
|
+
text: str
|
|
51
|
+
muted: str
|
|
52
|
+
accent: str
|
|
53
|
+
title_color: str
|
|
54
|
+
font_display: str
|
|
55
|
+
font_body: str
|
|
56
|
+
display_pt: int
|
|
57
|
+
h1_pt: int
|
|
58
|
+
body_pt: int
|
|
59
|
+
caption_pt: int
|
|
60
|
+
bullet_char: str = "▪"
|
|
61
|
+
|
|
62
|
+
# -- v1 renderer compatibility aliases (read-only) -----------------------
|
|
63
|
+
@property
|
|
64
|
+
def text_color(self) -> str:
|
|
65
|
+
"""Legacy alias for :attr:`text` (render/odp.py, pre-Phase-13)."""
|
|
66
|
+
return self.text
|
|
67
|
+
|
|
68
|
+
@property
|
|
69
|
+
def font(self) -> str:
|
|
70
|
+
"""Legacy alias for :attr:`font_body` (render/odp.py, pre-Phase-13)."""
|
|
71
|
+
return self.font_body
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
# (display, h1, body, caption) point sizes per density tier.
|
|
75
|
+
SCALES: dict[str, tuple[int, int, int, int]] = {
|
|
76
|
+
"compact": (44, 24, 16, 12),
|
|
77
|
+
"standard": (54, 28, 18, 13),
|
|
78
|
+
"display": (66, 32, 20, 14),
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
PAGE_W: float = 28.0
|
|
83
|
+
PAGE_H: float = 15.75
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
# ---------------------------------------------------------------------------
|
|
87
|
+
# Style (版式) — the layout personality, orthogonal to colour
|
|
88
|
+
#
|
|
89
|
+
# A Theme decides what a deck is *coloured* like; a Style decides what it is
|
|
90
|
+
# *composed* like. Recolouring alone produced thirteen decks that were
|
|
91
|
+
# recognisably one template — these switches are what make two templates two
|
|
92
|
+
# different documents.
|
|
93
|
+
#
|
|
94
|
+
# None of these compositions is invented here. Each follows a published, widely
|
|
95
|
+
# used convention, and the fields below are just the knobs those conventions
|
|
96
|
+
# actually differ on:
|
|
97
|
+
#
|
|
98
|
+
# * ``report`` — the MBB consulting slide: an action title top-left, a hairline
|
|
99
|
+
# rule under it, evidence below, source line bottom-left and page number
|
|
100
|
+
# bottom-right. Title 28–36pt / body 11–12pt / footnote 7–8pt.
|
|
101
|
+
# (deckary.com/blog/consulting-slide-standards, poesius.com consulting guides)
|
|
102
|
+
# * ``academic`` — the Beamer *metropolis* theme: minimal noise, frame title with
|
|
103
|
+
# a 0.4pt separator directly under it, section pages centred between two
|
|
104
|
+
# rules, a slim progress bar as the one decorative element.
|
|
105
|
+
# (github.com/matze/mtheme)
|
|
106
|
+
# * ``keynote`` — the full-bleed colour block with bottom-anchored text: bleed to
|
|
107
|
+
# at least one edge, text grounded in the lower third, furniture stripped to a
|
|
108
|
+
# page number. (slidemodel / slidegenius title-slide guides, Evergreen "Bleed
|
|
109
|
+
# your presentation")
|
|
110
|
+
# * ``editorial`` — Swiss/International Typographic Style: strict grid, bold
|
|
111
|
+
# headline running across the middle, spaced small-caps kicker, hairline at the
|
|
112
|
+
# top of the content area and almost no other furniture.
|
|
113
|
+
# * ``zen`` — the minimalist/design-forward layout: no rules at all; the title
|
|
114
|
+
# sits on the upper third rather than dead centre and whitespace does the work.
|
|
115
|
+
#
|
|
116
|
+
# Every field is a small enum consumed at exactly one place in the renderer, so
|
|
117
|
+
# adding a style stays a data edit rather than new drawing code.
|
|
118
|
+
# ---------------------------------------------------------------------------
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
@dataclass(frozen=True)
|
|
122
|
+
class Style:
|
|
123
|
+
"""One layout personality.
|
|
124
|
+
|
|
125
|
+
``cover`` — which entry in :data:`COVER_FRAMES` composes the opening page.
|
|
126
|
+
``cover_deco`` — ``rule-above`` 標題上方細線 · ``rule-under`` 標題下方通欄細線 ·
|
|
127
|
+
``masthead`` 頁面上緣通欄細線(Swiss 報頭) · ``bleed`` 滿版強調色出血 ·
|
|
128
|
+
``dots`` 點陣 · ``none``。
|
|
129
|
+
``title_mark`` — the content heading's mark: ``hairline`` 標題下通欄細線
|
|
130
|
+
(顧問報告) · ``separator`` 標題下 0.4pt 分隔線 (metropolis) ·
|
|
131
|
+
``kicker-rule`` 標題上方短線 (Swiss) · ``bar`` 左側色條 · ``none``。
|
|
132
|
+
``section`` — the divider page: ``numeral-left`` 淺底、左側巨大編號 ·
|
|
133
|
+
``centered-rules`` 置中標題、上下兩條細線 · ``bleed-numeral`` 滿版強調色 +
|
|
134
|
+
編號 · ``numeral-huge`` 淺底、超大編號壓在標題後 · ``dot`` 標題上方小圓點。
|
|
135
|
+
``footer`` — master furniture: ``rule`` 頁尾線 + 眉標 + 頁碼 ·
|
|
136
|
+
``progress`` 進度條 + 頁碼 · ``number`` 只有頁碼 · ``none``。
|
|
137
|
+
``card`` — how every visual-layout container (cards, process steps,
|
|
138
|
+
metrics, timeline events, comparison columns) is drawn: ``filled`` 圓角
|
|
139
|
+
底色卡 · ``ruled`` 無底色、頂端一條強調色線(顧問報告) · ``outlined``
|
|
140
|
+
細框線(Beamer block) · ``rule-ink`` 無底色、頂端墨色細線(Swiss) ·
|
|
141
|
+
``plain`` 不畫容器,只靠留白分組。Without this every style drew the same
|
|
142
|
+
grey boxes, which is what made six styles read as one template.
|
|
143
|
+
``takeaway`` — the "so what" band at the foot of a content page:
|
|
144
|
+
``band`` 強調色實心帶 · ``bar`` 淺底 + 左側強調色條 · ``box`` 細框 +
|
|
145
|
+
強調色小標 · ``bleed`` 滿版出血強調色帶 · ``rule`` 上方短線 + 粗體大字 ·
|
|
146
|
+
``quiet`` 置中、無裝飾。
|
|
147
|
+
"""
|
|
148
|
+
|
|
149
|
+
id: str
|
|
150
|
+
label: str
|
|
151
|
+
blurb: str
|
|
152
|
+
cover: str
|
|
153
|
+
cover_deco: str
|
|
154
|
+
title_mark: str
|
|
155
|
+
section: str
|
|
156
|
+
footer: str
|
|
157
|
+
invert_closing: bool
|
|
158
|
+
card: str = "filled"
|
|
159
|
+
takeaway: str = "band"
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
STYLES: dict[str, Style] = {
|
|
163
|
+
# The deck design ODForge shipped with: a centred cover over a dot lattice,
|
|
164
|
+
# a vertical accent bar beside每個內頁標題, and full-bleed dividers. Kept as
|
|
165
|
+
# a style rather than replaced — it is a real, tuned composition, and it is
|
|
166
|
+
# what every deck generated before this layer existed looks like.
|
|
167
|
+
"classic": Style(
|
|
168
|
+
id="classic",
|
|
169
|
+
label="學院派",
|
|
170
|
+
blurb="置中封面、標題左側色條、滿版分節頁。ODForge 原本的版面,穩定好用的通用選擇。",
|
|
171
|
+
cover="centered",
|
|
172
|
+
cover_deco="dots",
|
|
173
|
+
title_mark="bar",
|
|
174
|
+
section="bleed-numeral",
|
|
175
|
+
footer="rule",
|
|
176
|
+
invert_closing=True,
|
|
177
|
+
card="filled",
|
|
178
|
+
takeaway="band",
|
|
179
|
+
),
|
|
180
|
+
"report": Style(
|
|
181
|
+
id="report",
|
|
182
|
+
label="顧問報告",
|
|
183
|
+
blurb=(
|
|
184
|
+
"標題在左上、下方一條細線,出處與頁碼在頁尾。"
|
|
185
|
+
"MBB 顧問簡報的標準結構,最適合正式匯報與評鑑。"
|
|
186
|
+
),
|
|
187
|
+
cover="report",
|
|
188
|
+
cover_deco="rule-above",
|
|
189
|
+
title_mark="hairline",
|
|
190
|
+
section="numeral-left",
|
|
191
|
+
footer="rule",
|
|
192
|
+
invert_closing=False,
|
|
193
|
+
card="ruled",
|
|
194
|
+
takeaway="bar",
|
|
195
|
+
),
|
|
196
|
+
"academic": Style(
|
|
197
|
+
id="academic",
|
|
198
|
+
label="學術簡潔",
|
|
199
|
+
blurb=(
|
|
200
|
+
"標題下一條細分隔線、底部一條進度條、分節頁上下夾兩條線。"
|
|
201
|
+
"取自 Beamer metropolis 主題,適合論文口試與課堂。"
|
|
202
|
+
),
|
|
203
|
+
cover="academic",
|
|
204
|
+
cover_deco="rule-under",
|
|
205
|
+
title_mark="separator",
|
|
206
|
+
section="centered-rules",
|
|
207
|
+
footer="progress",
|
|
208
|
+
invert_closing=False,
|
|
209
|
+
card="outlined",
|
|
210
|
+
takeaway="box",
|
|
211
|
+
),
|
|
212
|
+
"keynote": Style(
|
|
213
|
+
id="keynote",
|
|
214
|
+
label="舞台",
|
|
215
|
+
blurb="封面整頁出血強調色、標題錨在下三分之一,內頁只有大字。適合上台講述與主題演講。",
|
|
216
|
+
cover="keynote",
|
|
217
|
+
cover_deco="bleed",
|
|
218
|
+
title_mark="none",
|
|
219
|
+
section="bleed-numeral",
|
|
220
|
+
footer="number",
|
|
221
|
+
invert_closing=True,
|
|
222
|
+
card="filled",
|
|
223
|
+
takeaway="band",
|
|
224
|
+
),
|
|
225
|
+
"editorial": Style(
|
|
226
|
+
id="editorial",
|
|
227
|
+
label="編輯風",
|
|
228
|
+
blurb="Swiss 網格:頂部通欄細線、粗標題橫貫中段、極少家具。適合人文、設計與展覽敘事。",
|
|
229
|
+
cover="editorial",
|
|
230
|
+
cover_deco="masthead",
|
|
231
|
+
title_mark="kicker-rule",
|
|
232
|
+
section="numeral-huge",
|
|
233
|
+
footer="number",
|
|
234
|
+
invert_closing=False,
|
|
235
|
+
card="rule-ink",
|
|
236
|
+
takeaway="rule",
|
|
237
|
+
),
|
|
238
|
+
# The "PASSPORT" reference deck's composition: white
|
|
239
|
+
# framed cards on a soft ground, a mono-tracked kicker under a short accent
|
|
240
|
+
# rule, and the page's conclusion as a dark panel down the right third —
|
|
241
|
+
# the asymmetric 2/3 + 1/3 split symmetric column layouts never produce.
|
|
242
|
+
"passport": Style(
|
|
243
|
+
id="passport",
|
|
244
|
+
label="護照",
|
|
245
|
+
blurb=(
|
|
246
|
+
"白色框線卡片、右側深色重點面板、頁首短線與字距標籤。"
|
|
247
|
+
"資訊密度最高的正式版式,適合審查、提案與成果報告。"
|
|
248
|
+
),
|
|
249
|
+
cover="report",
|
|
250
|
+
cover_deco="rule-above",
|
|
251
|
+
title_mark="kicker-rule",
|
|
252
|
+
section="numeral-left",
|
|
253
|
+
footer="rule",
|
|
254
|
+
invert_closing=True,
|
|
255
|
+
card="framed",
|
|
256
|
+
takeaway="panel",
|
|
257
|
+
),
|
|
258
|
+
"zen": Style(
|
|
259
|
+
id="zen",
|
|
260
|
+
label="極簡",
|
|
261
|
+
blurb="沒有線、沒有頁尾、沒有裝飾;標題落在上三分之一,留白自己說話。適合品牌與產品發表。",
|
|
262
|
+
cover="zen",
|
|
263
|
+
cover_deco="none",
|
|
264
|
+
title_mark="none",
|
|
265
|
+
section="dot",
|
|
266
|
+
footer="none",
|
|
267
|
+
invert_closing=False,
|
|
268
|
+
card="plain",
|
|
269
|
+
takeaway="quiet",
|
|
270
|
+
),
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
DEFAULT_STYLE = "classic"
|
|
274
|
+
|
|
275
|
+
# Which style each built-in palette ships with. Pairing them by hand is the
|
|
276
|
+
# point: 「墨金」 as an editorial print piece and 「深夜藍」 as a stage deck are two
|
|
277
|
+
# different templates, not two colourways of one.
|
|
278
|
+
THEME_STYLE: dict[str, str] = {
|
|
279
|
+
# The default palette keeps the default composition: a deck that names no
|
|
280
|
+
# style at all must look like it always did.
|
|
281
|
+
"academic": "classic",
|
|
282
|
+
"minimal": "zen",
|
|
283
|
+
"teal": "report",
|
|
284
|
+
"forest": "editorial",
|
|
285
|
+
"navy": "report",
|
|
286
|
+
"dark": "keynote",
|
|
287
|
+
"violet": "keynote",
|
|
288
|
+
"crimson": "academic",
|
|
289
|
+
"slate": "keynote",
|
|
290
|
+
"gold": "editorial",
|
|
291
|
+
"sky": "academic",
|
|
292
|
+
"plum": "editorial",
|
|
293
|
+
"clay": "zen",
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
|
|
297
|
+
def get_style(style_id: str | None) -> Style:
|
|
298
|
+
"""Resolve a style id, falling back to :data:`DEFAULT_STYLE`."""
|
|
299
|
+
return STYLES.get(style_id or DEFAULT_STYLE, STYLES[DEFAULT_STYLE])
|
|
300
|
+
|
|
301
|
+
|
|
302
|
+
# Cover geometry per ``Style.cover``. Only the opening page moves; the other
|
|
303
|
+
# layouts share one geometry and differ by the marks drawn on them, which keeps
|
|
304
|
+
# the layout budget (textmetrics) reasoning about one set of content frames.
|
|
305
|
+
#
|
|
306
|
+
# Margins follow the 0.75in (≈1.9cm) "comfortable standard" the slide-design
|
|
307
|
+
# guides converge on, with a deeper bottom margin than top for optical grounding.
|
|
308
|
+
COVER_FRAMES: dict[str, list[Frame]] = {
|
|
309
|
+
# The original centred cover.
|
|
310
|
+
"centered": [
|
|
311
|
+
Frame("title", 2, 5.5, 24, 3, 40, bold=True, center=True),
|
|
312
|
+
Frame("subtitle", 2, 9, 24, 2, 20, center=True),
|
|
313
|
+
],
|
|
314
|
+
# Consulting cover: title block anchored low-left, subtitle under it.
|
|
315
|
+
"report": [
|
|
316
|
+
Frame("title", 2.0, 8.6, 21.5, 2.6, 34, bold=True),
|
|
317
|
+
Frame("subtitle", 2.0, 11.5, 19.0, 1.6, 16),
|
|
318
|
+
],
|
|
319
|
+
# metropolis: title upper-left with the rule under the whole block.
|
|
320
|
+
"academic": [
|
|
321
|
+
Frame("title", 2.0, 5.0, 22.0, 2.8, 36, bold=True),
|
|
322
|
+
Frame("subtitle", 2.0, 8.9, 20.0, 1.6, 17),
|
|
323
|
+
],
|
|
324
|
+
# Bottom-anchored text on a full-bleed ground (lower third).
|
|
325
|
+
"keynote": [
|
|
326
|
+
Frame("title", 2.2, 9.5, 23.0, 3.0, 40, bold=True),
|
|
327
|
+
Frame("subtitle", 2.2, 12.7, 20.0, 1.5, 17),
|
|
328
|
+
],
|
|
329
|
+
# Swiss: headline running across the middle band, subtitle far below it.
|
|
330
|
+
"editorial": [
|
|
331
|
+
Frame("title", 2.0, 5.6, 23.0, 3.6, 44, bold=True),
|
|
332
|
+
Frame("subtitle", 2.0, 10.6, 18.0, 1.6, 16),
|
|
333
|
+
],
|
|
334
|
+
# Minimal: the title sits on the upper third, not dead centre.
|
|
335
|
+
"zen": [
|
|
336
|
+
Frame("title", 3.2, 4.9, 21.6, 2.8, 34, bold=True, center=True),
|
|
337
|
+
Frame("subtitle", 3.2, 8.2, 21.6, 1.5, 16, center=True),
|
|
338
|
+
],
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
|
|
342
|
+
# Divider-page geometry per ``Style.section``. Styles whose divider carries a
|
|
343
|
+
# numeral move the title out from under it; the rest keep the shared frame.
|
|
344
|
+
SECTION_FRAMES: dict[str, list[Frame]] = {
|
|
345
|
+
# Consulting: numeral on the left, title set beside it on the same optical
|
|
346
|
+
# line — not centred over it.
|
|
347
|
+
"numeral-left": [Frame("title", 7.6, 6.4, 18.4, 2.6, 34, bold=True)],
|
|
348
|
+
# Swiss: an oversized ghosted numeral with the title on the line below it.
|
|
349
|
+
"numeral-huge": [Frame("title", 2.0, 8.9, 22.0, 2.4, 34, bold=True)],
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
LAYOUTS: dict[str, list[Frame]] = {
|
|
353
|
+
"title": [
|
|
354
|
+
Frame("title", 2, 5.5, 24, 3, 40, bold=True, center=True),
|
|
355
|
+
Frame("subtitle", 2, 9, 24, 2, 20, center=True),
|
|
356
|
+
],
|
|
357
|
+
"title-content": [
|
|
358
|
+
Frame("title", 1.5, 0.55, 25, 2.4, 28, bold=True),
|
|
359
|
+
Frame("bullets", 1.5, 3.5, 25, 11, 18),
|
|
360
|
+
],
|
|
361
|
+
"two-col": [
|
|
362
|
+
Frame("title", 1.5, 0.55, 25, 2.4, 28, bold=True),
|
|
363
|
+
Frame("left", 1.5, 3.5, 12, 11, 16),
|
|
364
|
+
Frame("right", 14.5, 3.5, 12, 11, 16),
|
|
365
|
+
],
|
|
366
|
+
"section": [
|
|
367
|
+
Frame("title", 2, 6.5, 24, 3, 36, bold=True, center=True),
|
|
368
|
+
],
|
|
369
|
+
# The heading is drawn when the slide names one — a number with no
|
|
370
|
+
# heading read as a stray figure, and the title field the model always
|
|
371
|
+
# filled was silently dropped.
|
|
372
|
+
"big-fact": [
|
|
373
|
+
Frame("title", 1.5, 0.55, 25, 2.4, 28, bold=True),
|
|
374
|
+
Frame("fact", 2, 4.4, 24, 5.4, 48, bold=True, center=True),
|
|
375
|
+
Frame("bullets", 2, 10.4, 24, 2.8, 16, center=True),
|
|
376
|
+
],
|
|
377
|
+
# -- Task 14.1 page-role layouts ----------------------------------------
|
|
378
|
+
# size_pt values below are the 'standard' scale defaults; the renderer
|
|
379
|
+
# re-sizes these roles from the resolved Theme tokens (h1_pt / body_pt /
|
|
380
|
+
# caption_pt) so a per-deck DesignSpec scale is honoured, exactly as the
|
|
381
|
+
# 'fact' role is up-sized to display_pt.
|
|
382
|
+
"quote": [
|
|
383
|
+
Frame("quote", 3, 4.8, 22, 4.5, 28, center=True),
|
|
384
|
+
Frame("attribution", 3, 10, 22, 1.2, 13, center=True),
|
|
385
|
+
],
|
|
386
|
+
"agenda": [
|
|
387
|
+
Frame("title", 1.5, 0.55, 25, 2.4, 28, bold=True),
|
|
388
|
+
Frame("items", 3, 3.8, 22, 10.5, 18),
|
|
389
|
+
],
|
|
390
|
+
# 11.9cm columns leave a 0.7cm gutter between the two cards (each overhangs
|
|
391
|
+
# its frame by 0.3cm); at 12.2 the cards touched and read as one box.
|
|
392
|
+
"comparison": [
|
|
393
|
+
Frame("title", 1.5, 0.55, 25, 2.4, 28, bold=True),
|
|
394
|
+
Frame("left", 1.5, 3.6, 11.9, 10.9, 18),
|
|
395
|
+
Frame("right", 14.6, 3.6, 11.9, 10.9, 18),
|
|
396
|
+
],
|
|
397
|
+
"chart": [
|
|
398
|
+
Frame("title", 1.5, 0.55, 25, 2.4, 28, bold=True),
|
|
399
|
+
Frame("chart-area", 1.5, 3.5, 15.5, 11, 18),
|
|
400
|
+
Frame("insights", 17.6, 3.5, 8.9, 11, 13),
|
|
401
|
+
],
|
|
402
|
+
"process": [
|
|
403
|
+
Frame("title", 1.5, 0.55, 25, 2.4, 28, bold=True),
|
|
404
|
+
Frame("process-area", 1.5, 3.5, 25, 10.5, 16),
|
|
405
|
+
],
|
|
406
|
+
"timeline": [
|
|
407
|
+
Frame("title", 1.5, 0.55, 25, 2.4, 28, bold=True),
|
|
408
|
+
Frame("timeline-area", 1.5, 3.4, 25, 10.6, 16),
|
|
409
|
+
],
|
|
410
|
+
"metrics": [
|
|
411
|
+
Frame("title", 1.5, 0.55, 25, 2.4, 28, bold=True),
|
|
412
|
+
Frame("metrics-area", 1.5, 3.5, 25, 10.5, 16),
|
|
413
|
+
],
|
|
414
|
+
"cards": [
|
|
415
|
+
Frame("title", 1.5, 0.55, 25, 2.4, 28, bold=True),
|
|
416
|
+
Frame("cards-area", 1.5, 3.5, 25, 10.5, 16),
|
|
417
|
+
],
|
|
418
|
+
"diagram": [
|
|
419
|
+
Frame("title", 1.5, 0.55, 25, 2.4, 28, bold=True),
|
|
420
|
+
Frame("diagram-area", 1.5, 3.5, 25, 10.3, 16),
|
|
421
|
+
],
|
|
422
|
+
# Composite editorial page: a compact stat strip over a card grid — the
|
|
423
|
+
# "consulting one-pager" pattern (headline numbers + the ideas they carry).
|
|
424
|
+
# Both areas reuse the metrics/cards shape renderers unchanged.
|
|
425
|
+
"dashboard": [
|
|
426
|
+
Frame("title", 1.5, 0.55, 25, 2.4, 28, bold=True),
|
|
427
|
+
Frame("metrics-area", 1.5, 3.5, 25, 3.4, 16),
|
|
428
|
+
Frame("cards-area", 1.5, 7.3, 25, 6.8, 16),
|
|
429
|
+
],
|
|
430
|
+
# Comparison matrix: header row + up to 8 rows, one optionally highlighted.
|
|
431
|
+
"table": [
|
|
432
|
+
Frame("title", 1.5, 0.55, 25, 2.4, 28, bold=True),
|
|
433
|
+
Frame("table-area", 1.5, 3.3, 25, 10.7, 14),
|
|
434
|
+
],
|
|
435
|
+
"image-focus": [
|
|
436
|
+
Frame("title", 1.5, 0.55, 25, 2.4, 28, bold=True),
|
|
437
|
+
Frame("image-area", 1.5, 3.25, 25, 10.45, 16),
|
|
438
|
+
],
|
|
439
|
+
"image-split": [
|
|
440
|
+
Frame("title", 1.5, 0.55, 25, 2.4, 28, bold=True),
|
|
441
|
+
Frame("image-area", 1.5, 3.35, 13.4, 10.25, 16),
|
|
442
|
+
Frame("bullets", 16.0, 3.55, 10.5, 9.8, 17),
|
|
443
|
+
],
|
|
444
|
+
"closing": [
|
|
445
|
+
Frame("message", 2, 3.0, 24, 3, 28, bold=True, center=True),
|
|
446
|
+
# 5.8cm, not 4: the action cards are sized to their text, and four-across
|
|
447
|
+
# cards are narrow enough that a real action wraps to three or four lines.
|
|
448
|
+
# A closing page carries no footer furniture, so the room below is free —
|
|
449
|
+
# the row stays centred in this area, and capping it at 4cm was what made
|
|
450
|
+
# a long action clamp and print onto the inverted background.
|
|
451
|
+
Frame("closing-actions", 2, 6.9, 24, 6.2, 16),
|
|
452
|
+
],
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
|
|
456
|
+
# Layout / role sets shared by the renderer (render.odp) and the budget gate
|
|
457
|
+
# (textmetrics). Kept here — the single source both modules import — so a future
|
|
458
|
+
# layout change can never let the two drift apart (which would silently diverge
|
|
459
|
+
# the budget estimate from what the renderer actually draws).
|
|
460
|
+
#
|
|
461
|
+
# Layouts whose title frame renders "bare": no kicker eyebrow, no page-number /
|
|
462
|
+
# footer furniture (the opening title, the full-accent section divider, and the
|
|
463
|
+
# inverted closing page).
|
|
464
|
+
PLAIN_LAYOUTS: frozenset[str] = frozenset({"title", "section", "closing"})
|
|
465
|
+
# Frame roles whose (left-aligned) multi-item content renders as a semantic
|
|
466
|
+
# bullet list; centred frames (e.g. the big-fact caption) stay bare paragraphs.
|
|
467
|
+
LIST_ROLES: frozenset[str] = frozenset({"bullets", "left", "right"})
|
|
468
|
+
|
|
469
|
+
|
|
470
|
+
# ---------------------------------------------------------------------------
|
|
471
|
+
# Page header + foot: the lede line and the "so what" band
|
|
472
|
+
#
|
|
473
|
+
# A content page used to be a title and a box of evidence — nothing said what
|
|
474
|
+
# the evidence *meant*, and nothing told the reader what the page was about
|
|
475
|
+
# before they parsed it. The two frames below are what every hand-designed deck
|
|
476
|
+
# has and every generated one lacked: a one-line lede under the heading and a
|
|
477
|
+
# conclusion band at the foot. Both are optional per slide (``Slide.subtitle`` /
|
|
478
|
+
# ``Slide.takeaway``); when present, the body frames are re-flowed into the
|
|
479
|
+
# space that is left, so content never collides with either.
|
|
480
|
+
# ---------------------------------------------------------------------------
|
|
481
|
+
|
|
482
|
+
# Below the heading mark (hairline/separator end at ≈3.18cm). The heading
|
|
483
|
+
# frame is 2.4cm tall because a kicker (≈0.67cm) plus one 28pt CJK line
|
|
484
|
+
# (≈1.43cm at Noto's 1.45 line box) needs 2.1cm — at 2.0 the budget gate
|
|
485
|
+
# flagged every single content page, and an agent told "shorten flagged
|
|
486
|
+
# pages" could never finish.
|
|
487
|
+
LEDE_Y: float = 3.3
|
|
488
|
+
LEDE_H: float = 1.05
|
|
489
|
+
LEDE_PT: int = 16
|
|
490
|
+
# The body starts here when a lede is present.
|
|
491
|
+
CONTENT_TOP_WITH_LEDE: float = 4.85
|
|
492
|
+
# The band sits above the sources line (14.08cm) and the footer rule (14.9cm).
|
|
493
|
+
TAKEAWAY_Y: float = 12.5
|
|
494
|
+
TAKEAWAY_H: float = 1.35
|
|
495
|
+
TAKEAWAY_PT: int = 17
|
|
496
|
+
# The body ends here when a takeaway is present.
|
|
497
|
+
CONTENT_BOTTOM_WITH_TAKEAWAY: float = 11.8
|
|
498
|
+
|
|
499
|
+
# Layouts that carry a content heading — and therefore a lede/takeaway. The
|
|
500
|
+
# cover, divider and closing pages are compositions of their own; a quote page
|
|
501
|
+
# is the quote.
|
|
502
|
+
HEADED_LAYOUTS: frozenset[str] = frozenset(LAYOUTS) - PLAIN_LAYOUTS - {"quote"}
|
|
503
|
+
|
|
504
|
+
|
|
505
|
+
# Layouts whose body can give up its right third to a takeaway panel. Wide
|
|
506
|
+
# compositions (timelines, 5-step processes, tables, dashboards) keep the
|
|
507
|
+
# bottom band instead — squeezing them into 17cm costs more than it adds.
|
|
508
|
+
PANEL_LAYOUTS: frozenset[str] = frozenset(
|
|
509
|
+
{"cards", "title-content", "two-col", "comparison", "metrics", "big-fact", "diagram"}
|
|
510
|
+
)
|
|
511
|
+
PANEL_X: float = 19.2
|
|
512
|
+
PANEL_W: float = 7.3
|
|
513
|
+
PANEL_BODY_RIGHT: float = 18.6
|
|
514
|
+
|
|
515
|
+
|
|
516
|
+
def page_frames(
|
|
517
|
+
layout: str,
|
|
518
|
+
*,
|
|
519
|
+
lede: bool = False,
|
|
520
|
+
takeaway: bool = False,
|
|
521
|
+
panel: bool = False,
|
|
522
|
+
) -> list[Frame]:
|
|
523
|
+
"""The frames a content page is drawn into, given its optional lede/band.
|
|
524
|
+
|
|
525
|
+
Shared by the renderer and the layout-budget gate (the same reason
|
|
526
|
+
:data:`LAYOUTS` lives here): both must reason about one geometry. Without a
|
|
527
|
+
lede or takeaway this is exactly ``LAYOUTS[layout]``. With them, the body
|
|
528
|
+
frames (everything but the title) are mapped linearly from their original
|
|
529
|
+
vertical span into the space between the lede and the band — one rule that
|
|
530
|
+
keeps multi-area layouts (dashboard, chart, image-split) proportioned
|
|
531
|
+
instead of a per-layout table that would drift.
|
|
532
|
+
"""
|
|
533
|
+
frames = list(LAYOUTS[layout])
|
|
534
|
+
if layout not in HEADED_LAYOUTS or not (lede or takeaway):
|
|
535
|
+
return frames
|
|
536
|
+
if takeaway and panel and layout in PANEL_LAYOUTS:
|
|
537
|
+
return _panel_frames(frames, lede)
|
|
538
|
+
heads = [f for f in frames if f.role == "title"]
|
|
539
|
+
body = [f for f in frames if f.role != "title"]
|
|
540
|
+
old_top = min(f.y for f in body)
|
|
541
|
+
old_bottom = max(f.y + f.h for f in body)
|
|
542
|
+
new_top = max(old_top, CONTENT_TOP_WITH_LEDE) if lede else old_top
|
|
543
|
+
new_bottom = (
|
|
544
|
+
min(old_bottom, CONTENT_BOTTOM_WITH_TAKEAWAY) if takeaway else old_bottom
|
|
545
|
+
)
|
|
546
|
+
if layout == "dashboard":
|
|
547
|
+
# The stat strip has a floor (value + label need ≈3.3cm); scaling it
|
|
548
|
+
# with the card grid squeezed it to 2.5cm and printed labels over the
|
|
549
|
+
# cards. The strip keeps its height, the grid takes what is left.
|
|
550
|
+
strip, grid = body
|
|
551
|
+
strip = replace(strip, y=new_top, h=min(strip.h, 3.4))
|
|
552
|
+
grid_top = strip.y + strip.h + 0.4
|
|
553
|
+
body = [strip, replace(grid, y=grid_top, h=new_bottom - grid_top)]
|
|
554
|
+
else:
|
|
555
|
+
scale = (new_bottom - new_top) / (old_bottom - old_top)
|
|
556
|
+
body = [
|
|
557
|
+
replace(f, y=new_top + (f.y - old_top) * scale, h=f.h * scale)
|
|
558
|
+
for f in body
|
|
559
|
+
]
|
|
560
|
+
out = heads
|
|
561
|
+
if lede:
|
|
562
|
+
out.append(Frame("lede", 1.5, LEDE_Y, 25, LEDE_H, LEDE_PT))
|
|
563
|
+
out.extend(body)
|
|
564
|
+
if takeaway:
|
|
565
|
+
out.append(
|
|
566
|
+
Frame("takeaway", 1.5, TAKEAWAY_Y, 25, TAKEAWAY_H, TAKEAWAY_PT, bold=True)
|
|
567
|
+
)
|
|
568
|
+
return out
|
|
569
|
+
|
|
570
|
+
|
|
571
|
+
def _panel_frames(frames: list[Frame], lede: bool) -> list[Frame]:
|
|
572
|
+
"""Body into the left two-thirds, the takeaway as a full-height panel on
|
|
573
|
+
the right. Body frames are mapped linearly on both axes, like the band
|
|
574
|
+
reflow, so multi-area layouts keep their proportions."""
|
|
575
|
+
heads = [f for f in frames if f.role == "title"]
|
|
576
|
+
body = [f for f in frames if f.role != "title"]
|
|
577
|
+
old_top = min(f.y for f in body)
|
|
578
|
+
old_bottom = max(f.y + f.h for f in body)
|
|
579
|
+
old_left = min(f.x for f in body)
|
|
580
|
+
old_right = max(f.x + f.w for f in body)
|
|
581
|
+
top = max(old_top, CONTENT_TOP_WITH_LEDE) if lede else max(old_top, 3.5)
|
|
582
|
+
bottom = min(old_bottom, 14.0)
|
|
583
|
+
sy = (bottom - top) / (old_bottom - old_top)
|
|
584
|
+
sx = (PANEL_BODY_RIGHT - old_left) / (old_right - old_left)
|
|
585
|
+
body = [
|
|
586
|
+
replace(
|
|
587
|
+
f,
|
|
588
|
+
x=old_left + (f.x - old_left) * sx,
|
|
589
|
+
w=f.w * sx,
|
|
590
|
+
y=top + (f.y - old_top) * sy,
|
|
591
|
+
h=f.h * sy,
|
|
592
|
+
)
|
|
593
|
+
for f in body
|
|
594
|
+
]
|
|
595
|
+
out = heads
|
|
596
|
+
if lede:
|
|
597
|
+
out.append(Frame("lede", 1.5, LEDE_Y, 25, LEDE_H, LEDE_PT))
|
|
598
|
+
out.extend(body)
|
|
599
|
+
out.append(
|
|
600
|
+
Frame("takeaway", PANEL_X, top, PANEL_W, bottom - top, 20, bold=True)
|
|
601
|
+
)
|
|
602
|
+
return out
|
|
603
|
+
|
|
604
|
+
|
|
605
|
+
def _panel_fits(slide) -> bool:
|
|
606
|
+
"""A side panel takes a third of the width. Three cards or four metrics
|
|
607
|
+
in the other two-thirds set text 2–6 characters wide (「163 / .6 萬元」,
|
|
608
|
+
「SOP- / ER-017」), so those pages keep the bottom band instead."""
|
|
609
|
+
if slide.layout == "cards":
|
|
610
|
+
return len(slide.bullets) in (2, 4)
|
|
611
|
+
if slide.layout == "metrics":
|
|
612
|
+
return len(slide.metrics) <= 3
|
|
613
|
+
return True
|
|
614
|
+
|
|
615
|
+
|
|
616
|
+
def slide_frames(slide, style: Style | None = None) -> list[Frame]:
|
|
617
|
+
""":func:`page_frames` for a slide, reading its lede/takeaway fields; the
|
|
618
|
+
deck's ``style`` decides whether a takeaway is a band or a side panel."""
|
|
619
|
+
frames = page_frames(
|
|
620
|
+
slide.layout,
|
|
621
|
+
lede=bool(slide.subtitle.strip()),
|
|
622
|
+
takeaway=bool(slide.takeaway.strip()),
|
|
623
|
+
panel=style is not None and style.takeaway == "panel" and _panel_fits(slide),
|
|
624
|
+
)
|
|
625
|
+
if slide.layout == "chart" and not slide.bullets:
|
|
626
|
+
# No insights to show: the bars take the whole measure instead of
|
|
627
|
+
# stopping at 55% beside an empty column.
|
|
628
|
+
insights = next((f for f in frames if f.role == "insights"), None)
|
|
629
|
+
if insights is not None:
|
|
630
|
+
frames = [
|
|
631
|
+
replace(f, w=insights.x + insights.w - f.x)
|
|
632
|
+
if f.role == "chart-area"
|
|
633
|
+
else f
|
|
634
|
+
for f in frames
|
|
635
|
+
if f.role != "insights"
|
|
636
|
+
]
|
|
637
|
+
return frames
|
|
638
|
+
|
|
639
|
+
|
|
640
|
+
_STANDARD = SCALES["standard"]
|
|
641
|
+
|
|
642
|
+
|
|
643
|
+
def _preset(
|
|
644
|
+
*,
|
|
645
|
+
bg: str,
|
|
646
|
+
surface: str,
|
|
647
|
+
text: str,
|
|
648
|
+
muted: str,
|
|
649
|
+
accent: str,
|
|
650
|
+
font_display: str,
|
|
651
|
+
font_body: str,
|
|
652
|
+
title_color: str | None = None,
|
|
653
|
+
) -> Theme:
|
|
654
|
+
"""Build a preset Theme at the 'standard' scale (title_color defaults to text)."""
|
|
655
|
+
display_pt, h1_pt, body_pt, caption_pt = _STANDARD
|
|
656
|
+
return Theme(
|
|
657
|
+
bg=bg,
|
|
658
|
+
surface=surface,
|
|
659
|
+
text=text,
|
|
660
|
+
muted=muted,
|
|
661
|
+
accent=accent,
|
|
662
|
+
title_color=title_color if title_color is not None else text,
|
|
663
|
+
font_display=font_display,
|
|
664
|
+
font_body=font_body,
|
|
665
|
+
display_pt=display_pt,
|
|
666
|
+
h1_pt=h1_pt,
|
|
667
|
+
body_pt=body_pt,
|
|
668
|
+
caption_pt=caption_pt,
|
|
669
|
+
)
|
|
670
|
+
|
|
671
|
+
|
|
672
|
+
# Three built-in art directions. Colours are hand-picked to (a) read well and
|
|
673
|
+
# (b) clear the very contrast bars ir.Palette enforces (text/bg >= 4.5,
|
|
674
|
+
# accent/bg >= 3.0, muted/bg >= 3.0) — see the contrast tests.
|
|
675
|
+
THEMES: dict[str, Theme] = {
|
|
676
|
+
# 學術藍 + 暖白: a scholarly blue on warm off-white; serif display for gravitas.
|
|
677
|
+
"academic": _preset(
|
|
678
|
+
bg="#FBF9F4",
|
|
679
|
+
surface="#EFEADD",
|
|
680
|
+
text="#1F2733",
|
|
681
|
+
muted="#5B6470",
|
|
682
|
+
accent="#1A4B8C",
|
|
683
|
+
font_display="Noto Serif TC",
|
|
684
|
+
font_body="Noto Sans TC",
|
|
685
|
+
),
|
|
686
|
+
# 暖灰單色 + 一點橘: warm-grey monochrome lifted by a single burnt-orange accent.
|
|
687
|
+
"minimal": _preset(
|
|
688
|
+
bg="#FAF8F5",
|
|
689
|
+
surface="#ECE8E2",
|
|
690
|
+
text="#2B2926",
|
|
691
|
+
muted="#6E6A63",
|
|
692
|
+
accent="#C0560E",
|
|
693
|
+
font_display="Noto Sans TC",
|
|
694
|
+
font_body="Noto Sans TC",
|
|
695
|
+
),
|
|
696
|
+
# 深靛 + 亮青: deep indigo ground with a bright cyan accent; light text.
|
|
697
|
+
"dark": _preset(
|
|
698
|
+
bg="#171826",
|
|
699
|
+
surface="#252842",
|
|
700
|
+
text="#E8EAF2",
|
|
701
|
+
muted="#B4B9D8", # small detail text on the navy surface needs ~7:1
|
|
702
|
+
accent="#3DD6E6",
|
|
703
|
+
font_display="Noto Sans TC",
|
|
704
|
+
font_body="Noto Sans TC",
|
|
705
|
+
),
|
|
706
|
+
# 企業青綠: 2026 'Transformative Teal' on a cool near-white; calm/trustworthy.
|
|
707
|
+
"teal": _preset(
|
|
708
|
+
bg="#F4F7F7",
|
|
709
|
+
surface="#E4EDEC",
|
|
710
|
+
text="#1B2A2C",
|
|
711
|
+
muted="#556463",
|
|
712
|
+
accent="#0F766E",
|
|
713
|
+
font_display="Noto Sans TC",
|
|
714
|
+
font_body="Noto Sans TC",
|
|
715
|
+
),
|
|
716
|
+
# 森綠 + 奶油: deep forest green on warm cream, serif display; editorial/永續.
|
|
717
|
+
"forest": _preset(
|
|
718
|
+
bg="#F6F2E9",
|
|
719
|
+
surface="#E9E1CE",
|
|
720
|
+
text="#23291F",
|
|
721
|
+
muted="#5E5849",
|
|
722
|
+
accent="#2C6E49",
|
|
723
|
+
font_display="Noto Serif TC",
|
|
724
|
+
font_body="Noto Sans TC",
|
|
725
|
+
),
|
|
726
|
+
# 海軍藍 + 冷白: navy ink + electric-blue accent on cool white; corporate/SaaS.
|
|
727
|
+
"navy": _preset(
|
|
728
|
+
bg="#FAFBFD",
|
|
729
|
+
surface="#EAEEF5",
|
|
730
|
+
text="#16233F",
|
|
731
|
+
muted="#55617A",
|
|
732
|
+
accent="#2563EB",
|
|
733
|
+
font_display="Noto Sans TC",
|
|
734
|
+
font_body="Noto Sans TC",
|
|
735
|
+
),
|
|
736
|
+
# 午夜紫 + 電光紫: midnight-plum ground with a bright violet accent; creative/tech.
|
|
737
|
+
"violet": _preset(
|
|
738
|
+
bg="#1A1526",
|
|
739
|
+
surface="#2A2440",
|
|
740
|
+
text="#ECEAF4",
|
|
741
|
+
muted="#9A93B8",
|
|
742
|
+
accent="#B49BF5",
|
|
743
|
+
font_display="Noto Sans TC",
|
|
744
|
+
font_body="Noto Sans TC",
|
|
745
|
+
),
|
|
746
|
+
# 學院紅 + 暖白: crimson on a warm near-white, serif display; 校慶/人文/評鑑。
|
|
747
|
+
"crimson": _preset(
|
|
748
|
+
bg="#FCF8F7",
|
|
749
|
+
surface="#F1E5E3",
|
|
750
|
+
text="#2A1D1C",
|
|
751
|
+
muted="#6B5651",
|
|
752
|
+
accent="#A3212F",
|
|
753
|
+
font_display="Noto Serif TC",
|
|
754
|
+
font_body="Noto Sans TC",
|
|
755
|
+
),
|
|
756
|
+
# 石墨灰 + 冷藍: neutral graphite ground, calm blue accent; 工程/資安/夜間簡報。
|
|
757
|
+
"slate": _preset(
|
|
758
|
+
bg="#14181D",
|
|
759
|
+
surface="#212832",
|
|
760
|
+
text="#E8EDF4",
|
|
761
|
+
muted="#9CA9B8",
|
|
762
|
+
accent="#7FB2FF",
|
|
763
|
+
font_display="Noto Sans TC",
|
|
764
|
+
font_body="Noto Sans TC",
|
|
765
|
+
),
|
|
766
|
+
# 墨金: near-black ground with a restrained gold; 頒獎/成果發表/典禮。
|
|
767
|
+
"gold": _preset(
|
|
768
|
+
bg="#12100C",
|
|
769
|
+
surface="#221E17",
|
|
770
|
+
text="#F3EEE2",
|
|
771
|
+
muted="#B5A88E",
|
|
772
|
+
accent="#D9A441",
|
|
773
|
+
font_display="Noto Serif TC",
|
|
774
|
+
font_body="Noto Sans TC",
|
|
775
|
+
),
|
|
776
|
+
# 天青: cool white with a mid-blue accent; 教學/說明會的安全選擇。
|
|
777
|
+
"sky": _preset(
|
|
778
|
+
bg="#F7FAFD",
|
|
779
|
+
surface="#E6EEF7",
|
|
780
|
+
text="#152230",
|
|
781
|
+
muted="#526375",
|
|
782
|
+
accent="#0B6BA8",
|
|
783
|
+
font_display="Noto Sans TC",
|
|
784
|
+
font_body="Noto Sans TC",
|
|
785
|
+
),
|
|
786
|
+
# 梅紫 + 米白: light plum ground, magenta-leaning accent; 藝文/設計提案。
|
|
787
|
+
"plum": _preset(
|
|
788
|
+
bg="#FBF7FB",
|
|
789
|
+
surface="#F0E6F2",
|
|
790
|
+
text="#291D2C",
|
|
791
|
+
muted="#655A6B",
|
|
792
|
+
accent="#8A2A86",
|
|
793
|
+
font_display="Noto Serif TC",
|
|
794
|
+
font_body="Noto Sans TC",
|
|
795
|
+
),
|
|
796
|
+
# 陶土橘 + 米色: earthy clay on warm paper; 永續/地方創生/社區報告。
|
|
797
|
+
"clay": _preset(
|
|
798
|
+
bg="#FAF6F1",
|
|
799
|
+
surface="#EDE3D8",
|
|
800
|
+
text="#2C241C",
|
|
801
|
+
muted="#6B5C4C",
|
|
802
|
+
accent="#B4541F",
|
|
803
|
+
font_display="Noto Sans TC",
|
|
804
|
+
font_body="Noto Sans TC",
|
|
805
|
+
),
|
|
806
|
+
}
|
|
807
|
+
|
|
808
|
+
# 內建主題的顯示名稱。前端的範本庫與 CLI 的 --theme 說明共用同一份,新增一組
|
|
809
|
+
# 主題就是改 THEMES 與這裡兩處,不必再去追前端寫死的中文字串。
|
|
810
|
+
THEME_LABELS: dict[str, str] = {
|
|
811
|
+
"academic": "學術藍",
|
|
812
|
+
"minimal": "暖灰橘",
|
|
813
|
+
"teal": "企業青",
|
|
814
|
+
"forest": "森林綠",
|
|
815
|
+
"navy": "海軍藍",
|
|
816
|
+
"dark": "深夜藍",
|
|
817
|
+
"violet": "午夜紫",
|
|
818
|
+
"crimson": "學院紅",
|
|
819
|
+
"slate": "石墨灰",
|
|
820
|
+
"gold": "墨金",
|
|
821
|
+
"sky": "天青",
|
|
822
|
+
"plum": "梅紫",
|
|
823
|
+
"clay": "陶土橘",
|
|
824
|
+
}
|
|
825
|
+
|
|
826
|
+
|
|
827
|
+
def theme_scale(theme: Theme) -> str:
|
|
828
|
+
"""Which :data:`SCALES` tier a resolved theme's point sizes came from.
|
|
829
|
+
|
|
830
|
+
Used when a built-in preset is presented as an editable template: the
|
|
831
|
+
template gallery hands back a ``DesignSpec``, and a spec needs the tier name
|
|
832
|
+
rather than the four resolved sizes. Falls back to ``"standard"`` for a Theme
|
|
833
|
+
whose sizes were not taken from a tier (only reachable via a hand-built
|
|
834
|
+
Theme in tests).
|
|
835
|
+
"""
|
|
836
|
+
sizes = (theme.display_pt, theme.h1_pt, theme.body_pt, theme.caption_pt)
|
|
837
|
+
for name, tier in SCALES.items():
|
|
838
|
+
if sizes == tier:
|
|
839
|
+
return name
|
|
840
|
+
return "standard"
|
|
841
|
+
|
|
842
|
+
|
|
843
|
+
def resolve_style(p: Presentation) -> Style:
|
|
844
|
+
"""Resolve a presentation's layout personality.
|
|
845
|
+
|
|
846
|
+
An explicit ``p.style`` wins; otherwise the palette's paired default
|
|
847
|
+
(:data:`THEME_STYLE`) applies, so a deck that only names a preset still
|
|
848
|
+
gets that preset's intended composition rather than one house style for
|
|
849
|
+
everything.
|
|
850
|
+
"""
|
|
851
|
+
if p.style:
|
|
852
|
+
return get_style(p.style)
|
|
853
|
+
return get_style(THEME_STYLE.get(p.theme, DEFAULT_STYLE))
|
|
854
|
+
|
|
855
|
+
|
|
856
|
+
def resolve_design(p: Presentation) -> Theme:
|
|
857
|
+
"""Resolve a presentation's visual tokens into the single :class:`Theme`
|
|
858
|
+
the renderer consumes.
|
|
859
|
+
|
|
860
|
+
With no per-deck ``design`` the built-in preset ``THEMES[p.theme]`` is
|
|
861
|
+
returned unchanged. When ``p.design`` is present (already validated by
|
|
862
|
+
pydantic) its palette maps 1:1 onto the Theme colours, ``title_color``
|
|
863
|
+
follows ``text``, fonts come from the pairing, and the point sizes are taken
|
|
864
|
+
from :data:`SCALES` keyed by ``design.scale``. ``design.mode`` is a hint for
|
|
865
|
+
the LLM layer and deliberately does not affect sizing here.
|
|
866
|
+
"""
|
|
867
|
+
if p.design is None:
|
|
868
|
+
return THEMES[p.theme]
|
|
869
|
+
|
|
870
|
+
d = p.design
|
|
871
|
+
pal = d.palette
|
|
872
|
+
display_pt, h1_pt, body_pt, caption_pt = SCALES[d.scale]
|
|
873
|
+
return Theme(
|
|
874
|
+
bg=pal.bg,
|
|
875
|
+
surface=pal.surface,
|
|
876
|
+
text=pal.text,
|
|
877
|
+
muted=pal.muted,
|
|
878
|
+
accent=pal.accent,
|
|
879
|
+
title_color=pal.text,
|
|
880
|
+
font_display=d.fonts.display,
|
|
881
|
+
font_body=d.fonts.body,
|
|
882
|
+
display_pt=display_pt,
|
|
883
|
+
h1_pt=h1_pt,
|
|
884
|
+
body_pt=body_pt,
|
|
885
|
+
caption_pt=caption_pt,
|
|
886
|
+
)
|