AI turns documents or topics into real, native PowerPoint decks—with native shapes, transitions and animations, data-backed charts and tables on demand, audio narration from speaker notes, and support for your own .pptx templates. · by Hugo He
feat(svg-to-pptx): write locked template master text styles
hugohe35b115e1d8cd0
diff --git a/docs/roadmap.md b/docs/roadmap.mdindex e2f71a19..6c193668 100644--- a/docs/roadmap.md+++ b/docs/roadmap.md@@ -84,7 +84,7 @@ The past two months' structural capability growth. Single flags / incremental po- **`--native-objects` hardened from dormant marker to usable opt-in** — the narrow native-object exception (see Non-goals below) now emits charts and pure-text tables that keep the deck's own design instead of snapping to PowerPoint's white default theme. Classic native charts write explicit chart-area / plot-area / axis-line / gridline / label-text colors — inferred from the visible SVG fallback (largest panel `<rect>` → background, fallback text → labels, fallback strokes → axis/grid) or overridden per `style` (`chart_area_fill` / `plot_area_fill` / `text_color` / `axis_color` / `grid_color`, `"none"` for transparent); the color parser normalizes named CSS colors, `#RGB` shorthand, and `rgb()` / `rgba()` to OOXML hex; bar/column series disable negative-value fill inversion so negative bars keep their series color. The activated export is named `<name>_<ts>_native_charts.pptx` to tell it apart from the default flattened-shape export. **The default route is unchanged** — charts/tables still export as SVG-derived DrawingML shapes for cross-renderer fidelity; native objects stay the deliberate opt-in trade documented under Non-goals below-- **Native package structure + conservative PPTX object round-trip** — free-design baseline export promotes only safe shared backgrounds/chrome, assigns marker-backed Layout families, and may lift exact family-wide leading structurally marked chrome without inferring placeholders; marker-free legacy SVGs retain filename/id fallback. Template export deterministically compiles complete SVG pages whose Master/Layout/placeholder ownership is explicit. `create-template` uses imported source structure as analysis input and always rebuilds explicit SVG structure; strict keeps a selected Layout, adaptive may add a new Layout under the same Master. Legacy `preserve` remains compatibility-only. Raw one-off PPTX filling remains `template-fill-pptx`.+- **Native package structure + conservative PPTX object round-trip** — free-design baseline export promotes only safe shared backgrounds/chrome, assigns marker-backed Layout families, and may lift exact family-wide leading structurally marked chrome without inferring placeholders; marker-free legacy SVGs retain filename/id fallback. Template export deterministically compiles complete SVG pages whose Master/Layout/placeholder ownership is explicit and writes locked title/body sizes into Master `p:txStyles` without changing direct slide-run sizes. `create-template` uses imported source structure as analysis input and always rebuilds explicit SVG structure; strict keeps a selected Layout, adaptive may add a new Layout under the same Master. Legacy `preserve` remains compatibility-only. Raw one-off PPTX filling remains `template-fill-pptx`.---diff --git a/docs/technical-design.md b/docs/technical-design.mdindex 88dd4b0f..d64b5614 100644--- a/docs/technical-design.md+++ b/docs/technical-design.md@@ -456,6 +456,8 @@ These direct routes share some analysis primitives with the main pipeline, espec**Why reusable layouts require explicit SVG metadata.** `--pptx-structure template` is the opt-in path for a generated deck that must remain reusable as a PowerPoint template. The final slide SVGs declare a layout key at the root, mark only direct root children as master/layout layers, and attach typed placeholder semantics to the slide-local prototypes that should become layout placeholders. Export validates that shared master and same-key layout declarations are structurally and visually identical, then emits real layout parts and `p:ph` references while leaving every unmarked object slide-local. This is deterministic structure compilation, not visual-template inference.+**Why template-mode Master text styles are deliberately narrow.** Template export requires the locked `typography.title` and `typography.body` sizes, then writes the title size to every Master `p:titleStyle` level and the body size to every `p:bodyStyle` / `p:otherStyle` level. The patch changes only `p:txStyles//a:defRPr@sz`; direct run sizes on generated slides remain unchanged, so the authored SVG still controls initial rendering. Missing title/body locks fail template export, while `baseline`, `preserve`, and `flat` retain their previous behavior.+**Why reusable templates rebuild explicit SVG structure.** `pptx_template_import.py` emits layered Master/Layout/Slide references plus source structure facts. `create-template` uses those inputs to rebuild one clean Master and semantic Layouts as complete, explicitly annotated SVG pages; it does not package the original PPTX. Strict use keeps the selected Layout contract, while adaptive use may create a new Layout under the same Master. Both export through deterministic `template` mode. Legacy `preserve` remains readable for existing projects only. Raw PPTX plus one-off generated content still routes to `template-fill-pptx`.**Why each template SVG stays complete while still compiling to a Layout.** A generated SVG is a complete standalone preview, so it repeats inherited Master/Layout visuals together with its selectable Slide content. `page_layouts` names the input reference and `pptx_layouts` names the output Layout; both exist for every template page. Strict keeps the selected contract, while adaptive may lock a new Layout key under the same Master. Export removes repeated inherited copies and emits real Master/Layout parts, leaving actual content on the Slide.diff --git a/docs/zh/roadmap.md b/docs/zh/roadmap.mdindex 3853ff29..1c61bca7 100644--- a/docs/zh/roadmap.md+++ b/docs/zh/roadmap.md@@ -84,7 +84,7 @@- **`--native-objects` 从休眠 marker 硬化为可用级 opt-in** — 那条窄「原生对象」例外(见下文 Non-goals)现在导出的图表与纯文本表格会**保留 deck 自己的设计**,不再塌回 PowerPoint 的白底默认主题。classic 原生图表显式写入 chart-area / plot-area / 轴线 / 网格线 / 标签文字颜色——从可见的 SVG fallback 推断(最大面板型 `<rect>` → 背景、fallback 文字 → 标签、fallback 描边 → 轴线/网格),或用 `style` 显式覆盖(`chart_area_fill` / `plot_area_fill` / `text_color` / `axis_color` / `grid_color`,`"none"` 表透明);颜色解析把命名色、`#RGB` 简写、`rgb()` / `rgba()` 归一为 OOXML hex;bar/column 系列关掉负值反色,负值柱保持系列色。激活导出命名为 `<name>_<ts>_native_charts.pptx` 以与默认压平形状导出区分。**默认路线不变**——图表/表格仍以 SVG 派生的 DrawingML 形状导出以保跨渲染器保真;原生对象仍是下文 Non-goals 里那条刻意的 opt-in 取舍-- **原生 package 结构 + 保守 PPTX 对象回转** — 自由设计的 baseline 只提升安全共享背景/chrome,分配文件名页型 Layout,并可进一步提升家族内完全一致的前置 chrome,不推断 placeholder。模板路线则确定性编译完整 SVG 中显式声明的 Master/Layout/placeholder。`create-template` 只把源结构当分析输入并统一重建显式 SVG;`strict` 保持所选 Layout,`adaptive` 可在同一 Master 下新建 Layout。旧 `preserve` 仅保留兼容读取。+- **原生 package 结构 + 保守 PPTX 对象回转** — 自由设计的 baseline 只提升安全共享背景/chrome,分配文件名页型 Layout,并可进一步提升家族内完全一致的前置 chrome,不推断 placeholder。模板路线确定性编译完整 SVG 中显式声明的 Master/Layout/placeholder,并把锁定 title/body 字号写入母版 `p:txStyles`,不改变页面直接 run 字号。`create-template` 只把源结构当分析输入并统一重建显式 SVG;`strict` 保持所选 Layout,`adaptive` 可在同一 Master 下新建 Layout。旧 `preserve` 仅保留兼容读取;原始 PPTX 的一次性回填仍走 `template-fill-pptx`。---diff --git a/docs/zh/technical-design.md b/docs/zh/technical-design.mdindex 1805792b..2efc8094 100644--- a/docs/zh/technical-design.md+++ b/docs/zh/technical-design.md@@ -456,6 +456,8 @@ PowerPoint 的 DrawingML 是 SVG 表达力的严格子集。在转换器已实**为什么可复用版式必须依赖显式 SVG 元数据。** `--pptx-structure template` 是生成型 deck 需要继续作为 PowerPoint 模板复用时的 opt-in 路径。最终 slide SVG 在根节点声明 layout key,只允许根节点的直接子元素标记 master/layout layer,并在应成为版式占位框的 slide-local 原型上附加类型语义。导出器会验证共享 master 与同 key layout 的声明在结构和视觉上完全一致,再生成真实 layout part 与 `p:ph` 引用;所有未标记对象仍保持 slide-local。这是确定性的结构编译,不是根据视觉相似度猜模板。+**为什么 template 模式只做窄范围的母版文字样式补强。** Template 导出要求 `typography.title` 与 `typography.body` 两个锁定字号,把 title 写入母版 `p:titleStyle` 的全部层级,把 body 写入 `p:bodyStyle` / `p:otherStyle` 的全部层级。补丁只修改 `p:txStyles//a:defRPr@sz`;生成页面中的直接 run 字号保持不变,因此初始渲染仍由作者 SVG 控制。缺少 title/body 锁会让 template 导出失败,`baseline`、`preserve`、`flat` 则保持原有行为。+**为什么可复用模板统一重建显式 SVG 结构。** `pptx_template_import.py` 输出分层的 Master/Layout/Slide 参考和源结构事实;`create-template` 据此重建一个干净 Master 与语义 Layout,并把它们重复标注在可独立预览的完整 SVG 中,不再封装原 PPTX。严格套用保持所选 Layout 契约,自适应使用可在同一 Master 下新建显式 Layout;两者都走确定性的 `template` 导出。`preserve` 只为旧项目保留兼容读取。**为什么模板 SVG 保持完整却仍能编译成版式。** 每张生成 SVG 都是可独立预览的完整 slide,因此会重复携带继承的 Master/Layout 视觉和可选择的 Slide 内容。`page_layouts` 指定输入参考,`pptx_layouts` 指定输出版式,两者在模板路线中逐页齐全。严格模式保持所选契约;自适应模式可在同一 Master 下锁定新 Layout。导出器移除重复继承层并生成真实 Master/Layout,实际内容仍留在 Slide。diff --git a/skills/ppt-master/SKILL.md b/skills/ppt-master/SKILL.mdindex b36ff06b..4b656cb6 100644--- a/skills/ppt-master/SKILL.md+++ b/skills/ppt-master/SKILL.md@@ -787,6 +787,14 @@ python3 ${SKILL_DIR}/scripts/svg_to_pptx.py <project_path>> template use stay on this deterministic route. Adaptive pages may define new> layout keys, but they repeat the same Master layer and one internally> consistent Layout/placeholder contract.+> Template export also installs the locked `typography.title` size into every+> Master `titleStyle` level and the locked `typography.body` size into every+> `bodyStyle` and `otherStyle` level. It changes only existing+> `a:defRPr@sz` defaults: generated slide runs and Layout placeholder prototypes+> keep their direct sizes, while newly inserted/reset placeholder text inherits+> project defaults instead of Office fallback sizes. Missing or invalid locked+> title/body sizes fail template export. Baseline, preserve, and flat modes do+> not rewrite Master text-style sizes.> In template mode, `pptx_layouts` contains exactly one locked> layout key/name per page; reuse a key for a shared structure instead of> creating one key per content instance.diff --git a/skills/ppt-master/references/shared-standards.md b/skills/ppt-master/references/shared-standards.mdindex fbe2c9ac..b60ccb2c 100644--- a/skills/ppt-master/references/shared-standards.md+++ b/skills/ppt-master/references/shared-standards.md@@ -13,7 +13,7 @@ Other files link here instead of restating its contracts.| §4 Required Page Contract and Conditional Packaging | Complete-page authority, semantic markers, editable text/grouping, and package promotion | Required / Conditional || §5 Workflow Authority | Pointer to the serial post-processing/export procedure | Workflow pointer || §6 Advanced SVG Effects and Authoring Techniques | Color/alpha, gradients, shadows, glow, overlays, lines, text treatments, transforms, freeform geometry, chart geometry, and constructed visual styles | Contract + optional recipes |-| §7 Conditional PPT Interfaces | Pattern fills, native tables/charts, and Master/Layout/placeholder metadata | Conditional |+| §7 Conditional PPT Interfaces | Pattern fills, native tables/charts, Master text styles, and Master/Layout/placeholder metadata | Conditional || §8 Scope Boundary | Concerns intentionally owned by another reference or workflow | Boundary |**Advanced capability index**:@@ -1075,7 +1075,26 @@ match that row. Strict uses the selected template key/name. Adaptive may createa new key/name while repeating the same Master contract. Reuse one layout keyonly when pages share the same static Layout layer and placeholder contract;different content is not a reason to create a new layout. Direct diagnostic-exports may pass the CLI flag without a spec lock.+exports may select the mode with the CLI flag instead of a locked+`pptx_structure.mode` row, but still require `spec_lock.md` typography+`title` / `body` rows.++**Master text-style contract**: Template mode requires numeric `title` and+`body` rows under `spec_lock.md` `typography`. Export maps the locked `title`+size to every `a:defRPr` in Master `p:titleStyle`, and maps the locked `body`+size to every level in both `p:bodyStyle` and `p:otherStyle`.++| Master style | Locked source | XML field changed |+|---|---|---|+| `p:titleStyle` | `typography.title` | Every `a:defRPr@sz` |+| `p:bodyStyle` | `typography.body` | Every `a:defRPr@sz` |+| `p:otherStyle` | `typography.body` | Every `a:defRPr@sz` |++**Hard rule — narrow scope**: This update changes only Master+`p:txStyles//a:defRPr@sz`. It does not rewrite direct run sizes on generated+slides, so the initial slide rendering remains controlled by the authored SVG.+Missing `title` or `body` rows fail template export. `baseline`, `preserve`,+and `flat` modes do not apply this Master text-style update.| Metadata | Placement | Behavior ||---|---|---|diff --git a/skills/ppt-master/scripts/docs/svg-pipeline.md b/skills/ppt-master/scripts/docs/svg-pipeline.mdindex 455daf88..ffe5675d 100644--- a/skills/ppt-master/scripts/docs/svg-pipeline.md+++ b/skills/ppt-master/scripts/docs/svg-pipeline.md@@ -74,6 +74,7 @@ Behavior:- Omitting `--pptx-structure` reads `spec_lock.md` and falls back to `baseline`. Baseline assigns Layout families from root `data-pptx-page-role`, keeps content Slide-local, and promotes only exact family-wide backgrounds plus exact leading structurally marked chrome; filenames and ids are compatibility fallbacks for marker-free legacy SVGs. It never infers placeholders or visual similarity. Template mode builds reusable PowerPoint structure only from explicit SVG metadata and validates every `pptx_layouts` row plus cross-slide equality. Both strict and adaptive template adherence use this mode; adaptive may introduce a new Layout key under the same Master.- Template/preserve placeholder semantics distinguish title, subtitle, body, picture, chart, table, generic object, media, date, footer, and slide number. Reconstructed titles are normally type-matched without an index; explicit imported title indices and all other source indices are retained. Imported `subTitle`, `obj`, `media`, and `dt` identities remain distinct through `manifest.json`, `native_structure.json`, Layout XML, and Slide XML.- Baseline/template native export reads `spec_lock.md` typography into the PowerPoint theme: `title_family` becomes the major font and `body_family` / `font_family` becomes the minor font. Matching SVG text emits `+mj-*` / `+mn-*` tokens, while unrelated emphasis/code/brand families stay concrete. Preserve mode keeps the imported source theme; flat mode keeps fixed-font diagnostic output.+- Template mode also requires numeric `typography.title` and `typography.body` rows. It writes the title size to every Master `p:titleStyle` level and the body size to every `p:bodyStyle` / `p:otherStyle` level by changing only `a:defRPr@sz`. Direct slide-run sizes remain unchanged. Missing title/body rows fail template export; baseline, preserve, and flat modes do not apply this update.- Baseline/template native export also maps canonical `spec_lock.md` color roles into the PowerPoint color scheme and emits context-safe `schemeClr` tokens for exact matches in SVG fills/text/strokes, gradients/patterns/bullets, native tables, and native-chart accent series. Local colors, inverse white/black, and effects stay concrete. Preserve mode keeps the imported source color scheme; flat mode keeps fixed-color diagnostic output.- Preserve mode is legacy strict-only compatibility for existing projects that already carry `native_structure.json` + `source_template.pptx`. Current template creation does not emit the pair.- Native output uses content-hash media filenames, so identical images are reused and different images cannot overwrite each other by sharing a basename.diff --git a/skills/ppt-master/scripts/svg_to_pptx/drawingml/elements.py b/skills/ppt-master/scripts/svg_to_pptx/drawingml/elements.pyindex 54a8cb4f..3274b783 100644--- a/skills/ppt-master/scripts/svg_to_pptx/drawingml/elements.py+++ b/skills/ppt-master/scripts/svg_to_pptx/drawingml/elements.py@@ -25,7 +25,7 @@ from .utils import (combine_opacity, parse_hex_color, parse_svg_color,resolve_url_id, get_effective_filter_id,parse_inline_style, parse_font_family, is_cjk_char, estimate_text_width,- detect_text_lang, resolve_text_run_fonts,+ detect_text_lang, font_px_to_hpt, resolve_text_run_fonts,matrix_multiply, parse_transform_matrix, transform_point, _xml_escape,)from .styles import (@@ -1534,7 +1534,7 @@ def _build_run_xml(# rounded to **one decimal place of pt** (the nearest 10 hundredths). No 0.5pt# / integer snapping — whatever the px works out to is the size, e.g.# 18px -> 13.5pt, 24px -> 18.0pt, 42px -> 31.5pt.- sz = int(round(fs_px * FONT_PX_TO_HUNDREDTHS_PT / 10.0)) * 10+ sz = font_px_to_hpt(fs_px)b_attr = ' b="1"' if fw in ('bold', '600', '700', '800', '900') else ''i_attr = ' i="1"' if fstyle == 'italic' else ''u_attr = ' u="sng"' if 'underline' in text_dec else ''diff --git a/skills/ppt-master/scripts/svg_to_pptx/drawingml/theme_fonts.py b/skills/ppt-master/scripts/svg_to_pptx/drawingml/theme_fonts.pyindex 0280990b..559d6796 100644--- a/skills/ppt-master/scripts/svg_to_pptx/drawingml/theme_fonts.py+++ b/skills/ppt-master/scripts/svg_to_pptx/drawingml/theme_fonts.py@@ -1,18 +1,22 @@-"""Theme-font contracts shared by SVG conversion and PPTX package assembly."""+"""Theme typography contracts shared by SVG conversion and PPTX assembly."""from __future__ import annotations+import mathimport refrom dataclasses import dataclassfrom pathlib import Pathfrom xml.etree import ElementTree as ET-from .utils import parse_font_family+from .utils import FONT_PX_TO_HUNDREDTHS_PT, font_px_to_hpt, parse_font_familyDML_NS = "http://schemas.openxmlformats.org/drawingml/2006/main"+PML_NS = "http://schemas.openxmlformats.org/presentationml/2006/main"_LOCK_ROW_RE = re.compile(r"^-\s+([A-Za-z0-9_]+)\s*:\s*(.+?)\s*$")_CJK_THEME_SCRIPTS = frozenset({"Hans", "Hant", "Jpan", "Hang"})+_TEXT_FONT_SIZE_MIN = 100+_TEXT_FONT_SIZE_MAX = 400_000class ThemeFontError(RuntimeError):@@ -42,6 +46,14 @@ class ThemeFontSpec:minor_family: str+@dataclass(frozen=True)+class MasterTextStyleSpec:+ """Title/body defaults written to a template slide master's txStyles."""++ title_hpt: int+ body_hpt: int++def _font_face(font_family: str) -> ThemeFontFace:fonts = parse_font_family(font_family)return ThemeFontFace(@@ -91,6 +103,47 @@ def load_theme_font_spec(project_path: Path) -> ThemeFontSpec | None:)+def _font_size_hpt(raw: str, field: str) -> int:+ try:+ px = float(raw)+ except (TypeError, ValueError, OverflowError) as exc:+ raise ThemeFontError(+ f"spec_lock.md typography {field} must be a numeric px value: {raw!r}"+ ) from exc+ scaled = px * FONT_PX_TO_HUNDREDTHS_PT+ if not math.isfinite(scaled):+ raise ThemeFontError(+ f"spec_lock.md typography {field} must be finite: {raw!r}"+ )+ size = font_px_to_hpt(px)+ if not _TEXT_FONT_SIZE_MIN <= size <= _TEXT_FONT_SIZE_MAX:+ raise ThemeFontError(+ f"spec_lock.md typography {field} is outside the PowerPoint "+ f"font-size range: {raw!r}"+ )+ return size+++def load_master_text_style_spec(project_path: Path) -> MasterTextStyleSpec:+ """Load required title/body defaults for template slide-master txStyles."""+ lock_path = project_path / "spec_lock.md"+ if not lock_path.is_file():+ raise ThemeFontError(+ "template mode requires spec_lock.md typography title and body rows"+ )+ rows = _typography_rows(lock_path)+ missing = [field for field in ("title", "body") if field not in rows]+ if missing:+ raise ThemeFontError(+ "template mode requires spec_lock.md typography rows: "+ + ", ".join(missing)+ )+ return MasterTextStyleSpec(+ title_hpt=_font_size_hpt(rows["title"], "title"),+ body_hpt=_font_size_hpt(rows["body"], "body"),+ )++def theme_font_tokens(fonts: dict[str, str],spec: ThemeFontSpec | None,@@ -151,3 +204,82 @@ def apply_theme_font_spec(extract_dir: Path, spec: ThemeFontSpec) -> None:_patch_font_collection(major, spec.major)_patch_font_collection(minor, spec.minor)tree.write(theme_path, encoding="utf-8", xml_declaration=True)+++def _style_run_properties(style: ET.Element, label: str) -> list[ET.Element]:+ run_properties = list(style.iter(f"{{{DML_NS}}}defRPr"))+ if not run_properties:+ raise ThemeFontError(f"slide master {label} has no a:defRPr entries")+ return run_properties+++def apply_master_text_style_spec(+ extract_dir: Path,+ spec: MasterTextStyleSpec,+) -> int:+ """Install locked title/body sizes into template slide-master txStyles."""+ master_dir = extract_dir / "ppt" / "slideMasters"+ master_paths = sorted(master_dir.glob("slideMaster*.xml"))+ if not master_paths:+ raise ThemeFontError(f"PPTX package has no slide master under {master_dir}")++ ET.register_namespace("a", DML_NS)+ ET.register_namespace("p", PML_NS)+ for master_path in master_paths:+ try:+ tree = ET.parse(master_path)+ except (OSError, ET.ParseError) as exc:+ raise ThemeFontError(f"Cannot parse {master_path}: {exc}") from exc+ text_styles = tree.getroot().find(f"{{{PML_NS}}}txStyles")+ if text_styles is None:+ raise ThemeFontError(f"Slide master has no p:txStyles: {master_path}")++ style_sizes = (+ ("titleStyle", spec.title_hpt),+ ("bodyStyle", spec.body_hpt),+ ("otherStyle", spec.body_hpt),+ )+ for style_name, size in style_sizes:+ style = text_styles.find(f"{{{PML_NS}}}{style_name}")+ if style is None:+ raise ThemeFontError(+ f"Slide master has no p:{style_name}: {master_path}"+ )+ for run_properties in _style_run_properties(+ style,+ f"p:{style_name}",+ ):+ run_properties.set("sz", str(size))++ tree.write(master_path, encoding="utf-8", xml_declaration=True)++ try:+ read_back = ET.parse(master_path).getroot()+ except (OSError, ET.ParseError) as exc:+ raise ThemeFontError(+ f"Cannot read back slide master {master_path}: {exc}"+ ) from exc+ read_back_styles = read_back.find(f"{{{PML_NS}}}txStyles")+ if read_back_styles is None:+ raise ThemeFontError(+ f"Slide master lost p:txStyles after update: {master_path}"+ )+ for style_name, expected_size in style_sizes:+ style = read_back_styles.find(f"{{{PML_NS}}}{style_name}")+ actual_sizes = (+ {+ item.get("sz")+ for item in _style_run_properties(+ style,+ f"p:{style_name}",+ )+ }+ if style is not None+ else set()+ )+ if actual_sizes != {str(expected_size)}:+ raise ThemeFontError(+ f"Slide master p:{style_name} size read-back failed: "+ f"{master_path}"+ )+ return len(master_paths)diff --git a/skills/ppt-master/scripts/svg_to_pptx/drawingml/utils.py b/skills/ppt-master/scripts/svg_to_pptx/drawingml/utils.pyindex c7d4b0e2..9919c6aa 100644--- a/skills/ppt-master/scripts/svg_to_pptx/drawingml/utils.py+++ b/skills/ppt-master/scripts/svg_to_pptx/drawingml/utils.py@@ -146,6 +146,11 @@ def px_to_emu(px: float) -> int:return round(px * EMU_PER_PX)+def font_px_to_hpt(font_size_px: float) -> int:+ """Convert SVG px to DrawingML hundredths-of-a-point at 0.1pt precision."""+ return int(round(font_size_px * FONT_PX_TO_HUNDREDTHS_PT / 10.0)) * 10++def _f(val: str | None, default: float = 0.0) -> float:"""Parse a float attribute value, returning default if missing."""if val is None:diff --git a/skills/ppt-master/scripts/svg_to_pptx/native_objects/marker_common.py b/skills/ppt-master/scripts/svg_to_pptx/native_objects/marker_common.pyindex a86b9d7b..aae32d00 100644--- a/skills/ppt-master/scripts/svg_to_pptx/native_objects/marker_common.py+++ b/skills/ppt-master/scripts/svg_to_pptx/native_objects/marker_common.py@@ -17,6 +17,7 @@ from ..drawingml.utils import (ctx_w,ctx_x,ctx_y,+ font_px_to_hpt,matrix_multiply,parse_transform_matrix,transform_point,@@ -822,7 +823,7 @@ def _font_size_hpt(value: Any, default_px: int = 18) -> int:scaled = px * FONT_PX_TO_HUNDREDTHS_PTif not math.isfinite(scaled):return None- size = int(round(scaled / 10.0)) * 10+ size = font_px_to_hpt(px)if not _TEXT_FONT_SIZE_MIN <= size <= _TEXT_FONT_SIZE_MAX:return Nonereturn sizediff --git a/skills/ppt-master/scripts/svg_to_pptx/pptx_package/builder.py b/skills/ppt-master/scripts/svg_to_pptx/pptx_package/builder.pyindex 6cd8982a..83630187 100644--- a/skills/ppt-master/scripts/svg_to_pptx/pptx_package/builder.py+++ b/skills/ppt-master/scripts/svg_to_pptx/pptx_package/builder.py@@ -54,7 +54,9 @@ from ..drawingml.theme_colors import (rewrite_chart_accent_colors,)from ..drawingml.theme_fonts import (+ MasterTextStyleSpec,ThemeFontSpec,+ apply_master_text_style_spec,apply_theme_font_spec,)from ..drawingml.utils import EMU_PER_PX@@ -3335,6 +3337,7 @@ def create_pptx_with_native_svg(pptx_structure: str = "baseline",native_structure_contract: NativeStructureContract | None = None,theme_font_spec: ThemeFontSpec | None = None,+ master_text_style_spec: MasterTextStyleSpec | None = None,theme_color_spec: ThemeColorSpec | None = None,) -> bool:"""Create a PPTX file with native DrawingML shapes.@@ -3384,6 +3387,8 @@ def create_pptx_with_native_svg(``preserve`` mode.theme_font_spec: Locked project major/minor fonts for baseline/templatetheme inheritance. Preserve and flat modes ignore this value.+ master_text_style_spec: Required locked title/body sizes for template+ slide-master text styles. Other structure modes ignore this value.theme_color_spec: Locked project color scheme for context-awarebaseline/template theme inheritance. Preserve and flat modesignore this value.@@ -3403,6 +3408,11 @@ def create_pptx_with_native_svg(use_compat_mode = Falseif pptx_structure not in {"baseline", "template", "preserve", "flat"}:raise ValueError(f"Unsupported pptx_structure: {pptx_structure}")+ if pptx_structure == "template" and master_text_style_spec is None:+ raise ValueError(+ "Template export requires locked typography title/body sizes "+ "in master_text_style_spec"+ )if use_native_shapes and pptx_structure == "template":template_specs = parse_template_slides(svg_files)elif use_native_shapes and pptx_structure == "preserve":@@ -3547,6 +3557,18 @@ def create_pptx_with_native_svg()if active_theme_color_spec is not None:apply_theme_color_spec(extract_dir, active_theme_color_spec)+ if pptx_structure == "template":+ master_count = apply_master_text_style_spec(+ extract_dir,+ master_text_style_spec,+ )+ if verbose:+ print(+ " Template master text styles: "+ f"{master_count} master(s), "+ f"title {master_text_style_spec.title_hpt / 100:g}pt, "+ f"body {master_text_style_spec.body_hpt / 100:g}pt"+ )structure = _read_slide_layout_targets(extract_dir, len(svg_files))media_dir = extract_dir / 'ppt' / 'media'diff --git a/skills/ppt-master/scripts/svg_to_pptx/pptx_package/cli.py b/skills/ppt-master/scripts/svg_to_pptx/pptx_package/cli.pyindex 9184fddc..59328e44 100644--- a/skills/ppt-master/scripts/svg_to_pptx/pptx_package/cli.py+++ b/skills/ppt-master/scripts/svg_to_pptx/pptx_package/cli.py@@ -38,7 +38,11 @@ from .dimensions import CANVAS_FORMATS, get_project_info, get_viewbox_dimensionsfrom .discovery import find_svg_files, find_notes_filesfrom .builder import create_pptx_with_native_svgfrom ..drawingml.theme_colors import ThemeColorError, load_theme_color_spec-from ..drawingml.theme_fonts import ThemeFontError, load_theme_font_spec+from ..drawingml.theme_fonts import (+ ThemeFontError,+ load_master_text_style_spec,+ load_theme_font_spec,+)from .narration import NARRATION_EXTENSIONS, find_narration_files, probe_audio_durationfrom .slide_xml import TRANSITIONSfrom .template_structure import (@@ -345,10 +349,13 @@ Recorded narration:print(f"Error: {exc}", file=sys.stderr)return 1theme_font_spec = None+ master_text_style_spec = Nonetheme_color_spec = Noneif pptx_structure in {'baseline', 'template'}:try:theme_font_spec = load_theme_font_spec(project_path)+ if pptx_structure == 'template':+ master_text_style_spec = load_master_text_style_spec(project_path)theme_color_spec = load_theme_color_spec(project_path)except (ThemeFontError, ThemeColorError) as exc:print(f"Error: {exc}", file=sys.stderr)@@ -743,6 +750,7 @@ Recorded narration:pptx_structure=pptx_structure,native_structure_contract=native_structure_contract,theme_font_spec=theme_font_spec,+ master_text_style_spec=master_text_style_spec,theme_color_spec=theme_color_spec,)diff --git a/skills/ppt-master/templates/spec_lock_reference.md b/skills/ppt-master/templates/spec_lock_reference.mdindex e346456b..ac064acf 100644--- a/skills/ppt-master/templates/spec_lock_reference.md+++ b/skills/ppt-master/templates/spec_lock_reference.md@@ -75,6 +75,8 @@>> **Size slots are anchors, not a closed menu.** Common slots (`title` / `subtitle` / `annotation`) cover frequent cases. Add role-specific slots (e.g. `cover_title: 88`, `hero_number: 56`, `subheading: 32`, `lead: 30`, `footnote: 16`, `chart_annotation: 16`) for the roles the deck actually uses — common for cover-heavy decks, consulting-style hero numbers, dense pages. **Mandatory — scan `§IX` and declare a slot for every role that recurs across pages, not just the four defaults.** A report / `text`-mode deck almost always recurs a per-page **core-message / lead line** and **page numbers / source credits / footnotes** → declare `lead` and `footnote` for them. `subheading` and `lead` sit between `subtitle` and `body` (their bands overlap `subtitle`) — pick by role, not size — and the core-message `lead` is a **primary** line, **always ≥ `body`**, never smaller. Leaving a recurring lead / footnote undeclared forces the Executor to improvise an unlocked size (and a core line improvised below `body` inverts the hierarchy). **Structural roles (title / body / subtitle / annotation / footnote) render at their locked size on every page — one role, one size, deck-wide.** Intermediate in-band sizes are for special / feature elements only (hero number, display title, one-off emphasis); declare a recurring one as its own slot so it stays consistent too.>+> **Template Master defaults**: `pptx_structure.mode: template` requires both unitless `title` and `body`. Native export writes `title` into every Master `titleStyle` default and `body` into every `bodyStyle` / `otherStyle` default, changing only `a:defRPr@sz`. Direct page-run sizes and role-specific Layout placeholder prototype sizes remain unchanged. Other structure modes do not rewrite Master text-style sizes.+>> **⚠️ PPT-safe stack discipline (HARD rule).** Native `baseline` / `template` export maps `title_family` to the PowerPoint theme major font and `body_family` (or `font_family`) to the theme minor font. Runs whose resolved face matches either role use `+mj-*` / `+mn-*` theme tokens; other role families remain concrete per-run typefaces. Every exported Latin / EA face MUST therefore resolve to cross-platform pre-installed fonts: `"Microsoft YaHei"` / `SimSun` / `Arial` / `"Times New Roman"` / `Consolas`. Stacks that resolve to non-preinstalled typefaces (Inter / Google Fonts / brand typefaces) may be used only when the Design Spec notes the font-install or embedding requirement. `preserve` keeps the source template theme; `flat` keeps concrete fonts for diagnostics.>> **Stack length discipline.** 3-4 fonts per stack is the sweet spot. Converter only writes the **first** Latin and **first** CJK font into PPTX — everything after is silently dropped. macOS-only families (`Songti SC`, `Menlo`, `Monaco`, `Helvetica`) are auto-mapped to Windows equivalents via `FONT_FALLBACK_WIN` (see `scripts/svg_to_pptx/drawingml/utils.py`); stacking both is redundant. Lead with Windows-preinstalled fonts (`Microsoft YaHei` / `SimSun` / `Arial` / `Georgia` / `Consolas`); keep at most **one** macOS-exclusive family (typically `"PingFang SC"`) as a browser-preview nicety.