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(shape-boolean): support text outline operands
hugohe31b5160526b7f
diff --git a/docs/powerpoint-svg-mapping.md b/docs/powerpoint-svg-mapping.mdindex fd71d10a..a377bb2f 100644--- a/docs/powerpoint-svg-mapping.md+++ b/docs/powerpoint-svg-mapping.md@@ -95,7 +95,7 @@ Internal identifiers and PowerPoint display names are separate concerns: Master| Arrowhead line | `<line>` or supported path with registered triangle, stealth, arrow, diamond, or oval start/end markers | Native DrawingML line head/tail ends | `Native-normalized`; marker size is approximate | Marker definitions must follow the conditional marker contract || Native connector | Compact project-authored preset group with connector metadata and direct visible paths | `p:cxnSp` | Imported connectors retain the expanded round-trip evidence needed for source topology | `Native-stable` for the registered preset/connector schema || Freeform shape | `<path>` | `p:sp` with `a:custGeom` | Imported custom geometry reconstructs as a path | `Native-normalized`; SVG arcs are converted to cubic segments |-| Materialized Merge Shapes result | Ordinary `<path>` output from `shape_boolean_svg.py`; Fragment returns sibling paths | One `p:sp` with `a:custGeom` per returned path | `Native-normalized`; imports as final freeform geometry, not replayable operation history | Closed supported operands only; the first source owns style/order, and no clip, mask, or explicit fill rule is emitted |+| Materialized Merge Shapes result | Ordinary `<path>` output from `shape_boolean_svg.py`; Fragment returns sibling paths | One `p:sp` with `a:custGeom` per returned path | `Native-normalized`; imports as final freeform geometry, not replayable operation history | Supported closed geometry or horizontal implicit-LTR direct text with an exact resolvable font face; text becomes glyph geometry, the first source owns style/order, and no clip, mask, or explicit fill rule is emitted || Polygon | `<polygon>` | Closed custom geometry | `Native-normalized` | Points must be finite and valid || Polyline | `<polyline>` | Open custom geometry | `Native-normalized` | Points use the same finite, registered grammar as other generated geometry || PowerPoint preset shape | Registry-generated compact `<g>` with preset intent/base paint and direct visible `<path>` children | One editable preset `p:sp` | Preset identity and adjustments can survive import/export | Quality check and export rerender the registry dynamically; canonical authoring has no hidden carrier, preview wrapper, or stored preview hash |diff --git a/docs/zh/powerpoint-svg-mapping.md b/docs/zh/powerpoint-svg-mapping.mdindex 902defd6..d2c0d170 100644--- a/docs/zh/powerpoint-svg-mapping.md+++ b/docs/zh/powerpoint-svg-mapping.md@@ -95,7 +95,7 @@ PowerPoint 意图| 带箭头的线 | 带已登记 triangle、stealth、arrow、diamond 或 oval 起点/终点 marker 的 `<line>` 或受支持 path | 原生 DrawingML 线首/线尾 | `Native-normalized`;marker 大小为近似 | marker 定义必须遵循条件 marker 合同 || 原生连接符 | 带 connector metadata 和直接可见 path 的项目创作 compact preset 组 | `p:cxnSp` | 导入 connector 保留源拓扑往返所需的 expanded 证据 | 已登记 preset/connector schema 内为 `Native-stable` || 任意多边形 | `<path>` | 带 `a:custGeom` 的 `p:sp` | 导入自定义几何重建为 path | `Native-normalized`;SVG arc 转为三次曲线段 |-| 已物化的合并形状结果 | `shape_boolean_svg.py` 输出的普通 `<path>`;“拆分”返回多个同级 path | 每个返回 path 对应一个带 `a:custGeom` 的 `p:sp` | `Native-normalized`;回导为最终自由形状几何,不保留可重放的操作历史 | 仅接受受支持的闭合 operands;第一个 source 决定样式与顺序,且不输出 clip、mask 或显式 fill rule |+| 已物化的合并形状结果 | `shape_boolean_svg.py` 输出的普通 `<path>`;“拆分”返回多个同级 path | 每个返回 path 对应一个带 `a:custGeom` 的 `p:sp` | `Native-normalized`;回导为最终自由形状几何,不保留可重放的操作历史 | 接受受支持的闭合几何,或字体 face 可精确解析的隐式从左到右水平直接文本;文本会转为字形几何,第一个 source 决定样式与顺序,且不输出 clip、mask 或显式 fill rule || 多边形 | `<polygon>` | 闭合自定义几何 | `Native-normalized` | points 必须有限且合法 || 折线 | `<polyline>` | 开放自定义几何 | `Native-normalized` | points 使用与其他生成几何相同的有限、已登记语法 || PowerPoint 预设形状 | 由 registry 生成的 compact `<g>`,由该组承载 preset 意图与基础 paint,并直接包含可见 `<path>` 子元素 | 一个可编辑 preset `p:sp` | preset 身份与 adjustment 可以经导入/导出保留 | 质检与导出动态重渲染 registry;规范创作表达不含隐藏 carrier、preview wrapper 或已存储 preview hash |diff --git a/skills/ppt-master/references/executor-base.md b/skills/ppt-master/references/executor-base.mdindex f193da07..c12d807e 100644--- a/skills/ppt-master/references/executor-base.md+++ b/skills/ppt-master/references/executor-base.md@@ -178,7 +178,7 @@ content.| Straight relationship / divider / leader | Use `<line>`; add a registered marker only when direction is meaningful. || Exact single-preset match | Call `preset_shape_svg.py render` and paste its complete stdout fragment into the current hand-authored SVG. || Bent / curved relationship exactly expressed by a stock Connector contour, with no required endpoint attachment | Use the matching `bentConnector*` / `curvedConnector*` preset through the helper as an unconnected native Connector shape. |-| Two or more closed operands whose final semantic object depends on union, cutout, overlap-only coverage, symmetric difference, or fragmentation | Evaluate `shape_boolean_svg.py` at draw time and use it when Boolean materialization is the clearest faithful construction; follow [`native-shape-authoring.md`](./native-shape-authoring.md) §6. |+| Supported closed-shape / resolvable-text operands need union, cutout, overlap, symmetric difference, or fragmentation | Use `shape_boolean_svg.py` when Boolean materialization is the clearest faithful construction; follow [`native-shape-authoring.md`](./native-shape-authoring.md) §6. || Stock shape that needs a gradient fill/stroke or a pattern fill | Keep ordinary SVG — the helper paints `none` or a solid HEX on both fill and stroke only ([`native-shape-authoring.md`](./native-shape-authoring.md) §5). || Page-specific freeform, organic, branded, icon, data geometry, or relationship contour that primitives, one preset, and Boolean materialization cannot faithfully express | Keep ordinary SVG path/polygon geometry. || Similar-looking contour only | Never infer a preset; continue to the Boolean gate, then use freeform only if no faithful construction exists. |diff --git a/skills/ppt-master/references/image-layout-patterns.md b/skills/ppt-master/references/image-layout-patterns.mdindex ea72dd62..21feb112 100644--- a/skills/ppt-master/references/image-layout-patterns.md+++ b/skills/ppt-master/references/image-layout-patterns.md@@ -301,7 +301,7 @@ scrim/overlay shapes, a real cutout path, or a baked-alpha asset; never emit**Edge thickness**: to make the cut read as a physical opening, apply `feDropShadow` with `dx="0" dy="0"` and a small `stdDeviation` to the scrim path. Per [`svg-effects.md`](./svg-effects.md) §6.4 a zero-offset shadow is classified and exported as a **glow**, not a shadow — so use an accent or light color; black will read as diffuse haze rather than an edge. Never apply it to the `<image>` itself (#36).- **Numeral / lettering caveat**: cutting *text* out of the scrim needs the glyph as a `<path>` outline, which is not something to author by hand — least of all for CJK. Set the numeral as ordinary `<text>` over the scrim (nearly as strong, fully editable), or pre-render a knocked-out numeral as an RGBA PNG (#68). Do not approximate glyph outlines.+ **Numeral / lettering**: keep the glyph as ordinary horizontal `<text>`, then use `shape_boolean_svg.py render --operation subtract` to resolve its exact font face and cut the shaped outline from the scrim ([`native-shape-authoring.md`](./native-shape-authoring.md) §6). The result is editable freeform geometry, not editable text. Do not hand-trace glyphs; use a baked RGBA fallback only when the font or text structure cannot resolve.**Motion pairing**: the scrim stays fixed while the image beneath drifts slowly (a 4–10s linear path, left, starting with the previous animation) — the cuts then behave like windows onto a moving world. That is an animation-stage decision, not page design; see [`animations.md`](./animations.md). It pairs with this pattern more often than with any other.@@ -345,7 +345,7 @@ scrim/overlay shapes, a real cutout path, or a baked-alpha asset; never emit67. **Image with knock-out / cut-out shape** — overlay a shape filled with the background color or another image, creating the impression of a hole punched through the underlying image.-68. **Text-as-mask over image** — letterforms revealing image through them. Under the canonical SVG compatibility boundary in [`shared-standards-core.md`](./shared-standards-core.md), realize this pattern as a pre-rendered image rather than a runtime effect. Prompt for "large lettering revealing the underlying scene through letterforms" and treat the result as a fixed artistic choice.+68. **Text-as-mask over image** — letterforms revealing an image, gradient, texture, or solid field through them. Author the foreground as a closed shape and the lettering as supported direct `<text>`, then materialize Subtract with `shape_boolean_svg.py`; this produces an editable freeform with real glyph-shaped holes, without SVG `<mask>`. Use a pre-rendered RGBA treatment only when the font/text cannot resolve or the lettering must remain a fixed artistic asset.69. **Image rotated at a slight angle for editorial feel** — `transform="rotate(angle cx cy)"` on the `<image>` or its container `<g>`; 2–6 degrees typical. Adds dynamism without breaking layout.diff --git a/skills/ppt-master/references/native-shape-authoring.md b/skills/ppt-master/references/native-shape-authoring.mdindex 10a7f706..d5f05851 100644--- a/skills/ppt-master/references/native-shape-authoring.md+++ b/skills/ppt-master/references/native-shape-authoring.md@@ -4,9 +4,10 @@Use this reference during Executor SVG construction or project-owned canonicaltemplate maintenance when basic primitives, one standard PowerPoint shape, or-multiple closed shapes can express the intended object. Prefer, in order:+supported shape/text operands can express the intended object. Prefer, in order:editable basic primitives, one exact Office preset, then a PowerPoint-style-Boolean result. Hand-authored freeform geometry is allowed only when those+Boolean result from closed shapes and/or resolvable text. Hand-authored freeform+geometry is allowed only when thoseconstructions cannot faithfully express the object. Neither helper writes apage. The preset helper does not create the shape's own `p:txBody`; keep visibletext outside the atomic fragment.@@ -24,7 +25,7 @@ Apply this decision order before drawing any new geometric contour.| Straight relationship, divider, or leader | Write `<line>`; use a registered marker only when direction is meaningful. || One DrawingML preset exactly expresses the intended object | Run `preset_shape_svg.py render`, then insert its complete stdout fragment into the hand-authored page or canonical template. || A stock `bentConnector*` / `curvedConnector*` contour exactly expresses a bent or curved relationship and endpoint attachment is not required | Run `preset_shape_svg.py render --object-kind connector`; the result is an unconnected native Connector shape. |-| Two or more closed authored shapes require Union, Combine, Fragment, Intersect, or Subtract | Run `shape_boolean_svg.py render`, then replace the operands with every stdout path; the result remains ordinary editable custom geometry. |+| Two or more supported closed-shape / resolvable-text operands require Union, Combine, Fragment, Intersect, or Subtract | Run `shape_boolean_svg.py render`, then replace the operands with every stdout path; the result remains ordinary editable custom geometry. || Basic primitives, one preset, and Boolean materialization cannot faithfully express the visual meaning or contour | Write ordinary `<path>` / `<polygon>` geometry; export keeps it as editable custom geometry. || The shape only resembles a preset | Never infer a preset; continue to the Boolean gate, then use freeform only if no faithful construction exists. || Mirror/preserve input already owns native-shape metadata | Keep the existing object and metadata; never reselect its preset. |@@ -201,7 +202,7 @@ freshness contract.## 6. Shape Boolean Materialization-**Trigger**: Current page construction has two or more closed vector operands+**Trigger**: Current page construction has two or more supported shape/text operandswhose faithful result calls for PowerPoint-style Union, Combine, Fragment,Intersect, or Subtract. A §IX `Native shape suggestion` is a semantic candidate,not a prerequisite or tool command; Executor may adopt, adapt, or decline it@@ -217,7 +218,7 @@ python3 ${SKILL_DIR}/scripts/shape_boolean_svg.py render <svg-file> \| Concern | Contract ||---|---|-| Sources | Closed `path`, `polygon`, `rect`, `circle`, `ellipse`, or one validated compact authored shape preset. Open ordinary geometry, connectors, ordinary groups, text, images, definitions, and nested SVG viewports fail closed. |+| Sources | Closed `path`, `polygon`, `rect`, `circle`, `ellipse`, one validated compact authored shape preset, or supported horizontal implicit-LTR direct `<text>` with a resolvable exact OpenType weight/style (`--font-dir` adds search roots). Text becomes glyph geometry and is no longer editable text. Open geometry, groups, nested text, images, definitions, and nested SVG viewports fail closed. || Primary shape | The first `--source` supplies result paint. For `subtract`, all later operands are removed from that primary geometry. Explicit paint flags override only their named channels. || Coordinates | Ancestor and local transforms are baked into SVG-root coordinate space. Place stdout in the primary operand's z-order with no additional transform; never reinsert it under an original transformed ancestor. Root-coordinate space does not require each result path to be a direct `<svg>` child. || Placement | Ordinary Slide-local results belong in the applicable untransformed direct-root semantic `<g>` with its normal `id` / `data-pptx-bounds`. Master/Layout results remain direct-root path atoms and redeclare `data-pptx-layer`. One non-fragment result may be the direct `data-pptx-carrier="true"` child of an `object` slot. |diff --git a/skills/ppt-master/requirements.txt b/skills/ppt-master/requirements.txtindex 3f46a2a6..cd6ad82f 100644--- a/skills/ppt-master/requirements.txt+++ b/skills/ppt-master/requirements.txt@@ -18,6 +18,8 @@ python-pptx>=0.6.21XlsxWriter>=3.0.0# PowerPoint-style Merge Shapes materialization / PowerPoint 风格合并形状物化skia-pathops>=0.9.2+# OpenType shaping + glyph outlines for text operands / 文字 operand 的排版与轮廓+uharfbuzz>=0.50.0# Recorded narration / 录制计时和旁白# notes_to_audio.py generates per-slide narration audio on macOS/Linux/Windows.diff --git a/skills/ppt-master/scripts/README.md b/skills/ppt-master/scripts/README.mdindex 212b80c4..cb2ed446 100644--- a/skills/ppt-master/scripts/README.md+++ b/skills/ppt-master/scripts/README.md@@ -223,7 +223,11 @@ python3 scripts/shape_boolean_svg.py render slide.svg \The first source owns result paint and is the primary geometry for `subtract`.Local and ancestor transforms are baked into SVG-root coordinates. Replace theoperands with every returned path at the root in the primary operand's z-order;-`fragment` returns multiple stable sibling paths. See+`fragment` returns multiple stable sibling paths. Operands may be supported+closed geometry or supported horizontal implicit-LTR direct `<text>` whose exact+OpenType weight/style can be resolved; repeat `--font-dir PATH` for additional+font roots. Text is shaped to glyph outlines before the operation, so the+result remains editable freeform geometry but is no longer editable text. See[`references/native-shape-authoring.md`](../references/native-shape-authoring.md)§6 for the closed operand and failure contract.diff --git a/skills/ppt-master/scripts/docs/svg-pipeline.md b/skills/ppt-master/scripts/docs/svg-pipeline.mdindex cc48f282..29f57bee 100644--- a/skills/ppt-master/scripts/docs/svg-pipeline.md+++ b/skills/ppt-master/scripts/docs/svg-pipeline.md@@ -153,6 +153,12 @@ source.write_text(fill="#2563EB" stroke="#0F172A" stroke-width="5"stroke-dasharray="10 4"/><circle id="cutout" cx="240" cy="160" r="70" fill="#F97316"/>+ <text id="text-cutout" x="240" y="235" text-anchor="middle"+ font-family="sans-serif" font-size="180" font-weight="700">01</text>+ <text id="missing-font" x="240" y="235"+ font-family="Definitely Missing Font" font-size="80">X</text>+ <text id="nested-text" x="240" y="235"+ font-family="sans-serif" font-size="80"><tspan>X</tspan></text><path id="open" d="M 40 320 L 260 320 L 260 420" fill="#2563EB"/><rect id="clipped" x="40" y="320" width="160" height="100"clip-path="url(#clip)" fill="#2563EB"/>@@ -174,17 +180,18 @@ source.write_text()operations = [- ("union", "preset-source", "preset-cut"),- ("combine", "body", "cutout"),- ("fragment", "body", "cutout"),- ("intersect", "body", "cutout"),- ("subtract", "body", "cutout"),+ ("union", "union", "preset-source", "preset-cut"),+ ("combine", "combine", "body", "cutout"),+ ("fragment", "fragment", "body", "cutout"),+ ("intersect", "intersect", "body", "cutout"),+ ("subtract", "subtract", "body", "cutout"),+ ("text-subtract", "subtract", "body", "text-cutout"),]expected_custom_shapes = 0-for index, (operation, first, second) in enumerate(operations, start=1):+for index, (name, operation, first, second) in enumerate(operations, start=1):fragment = run_tool("shape_boolean_svg.py", "render", source, "--operation", operation,- "--source", first, "--source", second, "--id", f"result-{operation}",+ "--source", first, "--source", second, "--id", f"result-{name}",)paths = list(ET.fromstring(@@ -199,12 +206,12 @@ for index, (operation, first, second) in enumerate(operations, start=1):if operation == "fragment":assert len(paths) > 1assert [path.get("id") for path in paths] == [- f"result-fragment-{piece}"+ f"result-{name}-{piece}"for piece in range(1, len(paths) + 1)]else:assert len(paths) == 1- assert paths[0].get("id") == f"result-{operation}"+ assert paths[0].get("id") == f"result-{name}"if operation == "combine":assert all(path.get("stroke-width") == "6" for path in paths)assert all(path.get("stroke-dasharray") == "12 4.8" for path in paths)@@ -212,7 +219,7 @@ for index, (operation, first, second) in enumerate(operations, start=1):assert (paths[0].get("d") or "").count("M ") >= 2expected_custom_shapes += len(paths)- (svg_output / f"{index:02d}_{operation}.svg").write_text(+ (svg_output / f"{index:02d}_{name}.svg").write_text('<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1280 720" ''data-pptx-page-role="content">''<rect x="0" y="0" width="1280" height="720" fill="#FFFFFF"/>'@@ -237,6 +244,8 @@ rejections = [("union", "body", "imported", "PPTX import/round-trip metadata"),("union", "body", "dashoffset", "stroke-dashoffset"),("intersect", "body", "far", "produced no filled area"),+ ("subtract", "body", "missing-font", "cannot resolve an installed font"),+ ("subtract", "body", "nested-text", "child content is unsupported"),]for operation, first, second, expected_error in rejections:rejected = subprocess.run(@@ -269,7 +278,7 @@ with zipfile.ZipFile(pptx) as archive:archive.read(name).count(b"<a:custGeom>")for name in slides)-assert len(slides) == 5, slides+assert len(slides) == len(operations), slidesassert custom_shapes == expected_custom_shapesreadback = project / "readback"@@ -282,7 +291,7 @@ readback_custom_shapes = sum(slide.read_text(encoding="utf-8").count('data-pptx-custgeom="')for slide in slides)-assert len(slides) == 5, slides+assert len(slides) == len(operations), slidesassert readback_custom_shapes == expected_custom_shapesprint(f"Shape Boolean smoke: passed "@@ -291,10 +300,11 @@ print(PY```-The five inline negative cases must return nonzero and match their expected+The seven inline negative cases must return nonzero and match their expectederrors; every other command must pass. Open the printed-`boolean-smoke.pptx` path in PowerPoint: the Subtract result must have a real-hole, and every Fragment sibling must remain separately selectable.+`boolean-smoke.pptx` path in PowerPoint: both shape-cut and text-cut Subtract+results must have real holes, and every Fragment sibling must remain separately+selectable.## `compact_svg_coordinates.py`diff --git a/skills/ppt-master/scripts/prompt_audit_manifest.json b/skills/ppt-master/scripts/prompt_audit_manifest.jsonindex de4bc10e..69cacd1f 100644--- a/skills/ppt-master/scripts/prompt_audit_manifest.json+++ b/skills/ppt-master/scripts/prompt_audit_manifest.json@@ -12,7 +12,7 @@"skills/ppt-master/templates/schemas/*.json"],"exclude": [],- "max_tokens": 402100+ "max_tokens": 402440},"file_budgets": {"AGENTS.md": 2400,@@ -227,7 +227,7 @@"files": ["skills/ppt-master/scripts/docs/image.md"],- "max_tokens": 47150+ "max_tokens": 47160},"route.generate.quick-generate.ai-two-types": {"description": "Quick Generate with AI resource preparation, representative rendering inputs, and two local image types.",@@ -238,7 +238,7 @@"stage.generate.executor.image"],"files": [],- "max_tokens": 67000+ "max_tokens": 67015},"route.generate.quick-generate.web-image": {"description": "Quick Generate with web resource preparation, provenance, attribution, and image execution.",@@ -698,7 +698,7 @@"skills/ppt-master/scripts/docs/pptx-transitions.md","skills/ppt-master/scripts/docs/svg-pipeline.md"],- "max_tokens": 30300+ "max_tokens": 30490},"stage.generate.video-motion-plan": {"description": "Conditional resolved animation-to-video handoff contract.",diff --git a/skills/ppt-master/scripts/shape_boolean_svg.py b/skills/ppt-master/scripts/shape_boolean_svg.pyindex 588d7bf1..f8ac8ee7 100644--- a/skills/ppt-master/scripts/shape_boolean_svg.py+++ b/skills/ppt-master/scripts/shape_boolean_svg.py@@ -2,11 +2,11 @@"""PPT Master - Shape Boolean SVG Fragment Tool-Combine closed SVG shapes and print the resulting canonical SVG path fragment-to stdout. Result geometry is in SVG-root coordinate space: replace the-operands at their original z-order under the final semantic or structured-parent, never under the old transformed ancestor. The source SVG is read-only;-this tool never rewrites the page.+Combine closed SVG shapes or resolvable text outlines and print the resulting+canonical SVG path fragment to stdout. Result geometry is in SVG-root coordinate+space: replace the operands at their original z-order under the final semantic+or structured parent, never under the old transformed ancestor. The source SVG+is read-only; this tool never rewrites the page.Usage:python3 scripts/shape_boolean_svg.py render SVG_FILE \@@ -18,9 +18,11 @@ Examples:python3 scripts/shape_boolean_svg.py render slide.svg \--operation subtract --source body --source cutout --id result \--fill "#2563EB" --stroke none+ python3 scripts/shape_boolean_svg.py render cover.svg \+ --operation subtract --source scrim --source chapter-number --id revealDependencies:- skia-pathops and local PPT Master modules+ skia-pathops, local PPT Master modules, and uharfbuzz for text operands"""from __future__ import annotations@@ -40,11 +42,11 @@ configure_utf8_stdio()def build_parser() -> argparse.ArgumentParser:parser = argparse.ArgumentParser(description=(- "Print the Boolean result of closed SVG shapes as canonical SVG "- "path fragments in SVG-root coordinate space. Insert the result at "- "the original z-order under the final semantic or structured "- "parent, never under the old transformed ancestor. The source file "- "is never modified."+ "Print the Boolean result of closed SVG shapes or resolvable text "+ "outlines as canonical SVG path fragments in SVG-root coordinate "+ "space. Insert the result at the original z-order under the final "+ "semantic or structured parent, never under the old transformed "+ "ancestor. The source file is never modified."),formatter_class=argparse.RawDescriptionHelpFormatter,)@@ -82,6 +84,18 @@ def build_parser() -> argparse.ArgumentParser:dest="output_id",help="Stable id for the result, or the base id for fragment results.",)+ render_parser.add_argument(+ "--font-dir",+ action="append",+ default=[],+ dest="font_dirs",+ type=Path,+ metavar="PATH",+ help=(+ "Additional font directory for text operands; repeat as needed. "+ "Explicit directories are searched before system font directories."+ ),+ )render_parser.add_argument("--fill",help="Override the primary shape's solid SVG fill, or use none.",@@ -125,6 +139,7 @@ def main(argv: Sequence[str] | None = None) -> int:source_ids=args.source_ids,output_id=args.output_id,style=style or None,+ font_dirs=args.font_dirs,)except (OSError, RuntimeError, ValueError) as exc:print(f"Error: {exc}", file=sys.stderr)@@ -141,6 +156,9 @@ def _validate_render_args(args: argparse.Namespace) -> None:raise ValueError("--source ids must be unique")if not args.output_id.strip():raise ValueError("--id must not be empty")+ for font_dir in args.font_dirs:+ if not font_dir.is_dir():+ raise ValueError(f"--font-dir is not a directory: {font_dir}")def _style_from_args(args: argparse.Namespace) -> dict[str, str]:diff --git a/skills/ppt-master/scripts/svg_to_pptx/shape_boolean.py b/skills/ppt-master/scripts/svg_to_pptx/shape_boolean.pyindex d3e2cf90..8cd7cab0 100644--- a/skills/ppt-master/scripts/svg_to_pptx/shape_boolean.py+++ b/skills/ppt-master/scripts/svg_to_pptx/shape_boolean.py@@ -2,8 +2,8 @@"""PPT Master - Shape Boolean Core-Resolve closed SVG operands into SVG-root-coordinate paths and apply-PowerPoint-compatible merge-shapes operations without mutating the source SVG.+Resolve closed SVG or text-outline operands into SVG-root-coordinate paths and+apply PowerPoint-compatible merge-shapes operations without mutating the source.Callers insert returned paths at the original z-order under the final semanticor structured parent, never under the old transformed ancestor.@@ -19,7 +19,7 @@ Examples:)Dependencies:- skia-pathops and local PPT Master modules+ skia-pathops, local PPT Master modules, and uharfbuzz for text operands"""from __future__ import annotations@@ -117,6 +117,7 @@ def render_boolean_svg_fragments(source_ids: Sequence[str],output_id: str,style: Mapping[str, str] | None = None,+ font_dirs: Sequence[str | Path] = (),) -> str:"""Return canonical SVG path fragments for one merge-shapes operation.@@ -172,7 +173,12 @@ def render_boolean_svg_fragments(pathops = _load_pathops()operands = [- _element_to_pathops(element, parents, pathops)+ _element_to_pathops(+ element,+ parents,+ pathops,+ font_dirs=font_dirs,+ )for element in selected]inherited_style = _materialize_baked_stroke_style(@@ -315,6 +321,8 @@ def _element_to_pathops(element: ET.Element,parents: Mapping[ET.Element, ET.Element],pathops: Any,+ *,+ font_dirs: Sequence[str | Path] = (),) -> Any:chain = _element_chain(element, parents)_validate_source_location(element, chain)@@ -326,11 +334,20 @@ def _element_to_pathops(elif tag in _BOOLEAN_TAGS:commands = _shape_commands(element)commands = transform_path_commands(commands, matrix)+ elif tag == "text":+ from .text_outline import text_element_to_path_commands++ commands = text_element_to_path_commands(+ element,+ parents,+ font_dirs=font_dirs,+ )+ commands = transform_path_commands(commands, matrix)else:- supported = ", ".join(sorted(_BOOLEAN_TAGS))+ supported = ", ".join((*sorted(_BOOLEAN_TAGS), "text"))raise ValueError(- f"Shape Boolean source {_element_label(element)} must be a closed "- f"{supported}, or a compact authored preset group"+ f"Shape Boolean source {_element_label(element)} must be a "+ f"supported {supported}, or a compact authored preset group")result = _simplify_path(_commands_to_pathops(commands, pathops), pathops)diff --git a/skills/ppt-master/scripts/svg_to_pptx/text_outline.py b/skills/ppt-master/scripts/svg_to_pptx/text_outline.pynew file mode 100644index 00000000..fe6d923b--- /dev/null+++ b/skills/ppt-master/scripts/svg_to_pptx/text_outline.py@@ -0,0 +1,1121 @@+#!/usr/bin/env python3+"""+PPT Master - Text Outline Materialization++Resolve one supported SVG ``<text>`` operand into closed glyph-outline path+commands for the Shape Boolean geometry pipeline.++Usage:+ Import text_element_to_path_commands from svg_to_pptx.text_outline.++Dependencies:+ uharfbuzz and local PPT Master modules+"""++from __future__ import annotations++import bisect+import math+import os+import sys+import unicodedata+from collections.abc import Mapping, Sequence+from dataclasses import dataclass+from functools import lru_cache+from pathlib import Path+from typing import Any+from xml.etree import ElementTree as ET++from .drawingml.paths import PathCommand, normalize_path_commands+from .drawingml.text_properties import (+ normalize_project_text_segments,+ parse_project_font_style,+ parse_project_font_weight,+ parse_project_letter_spacing,+ parse_project_text_anchor,+ parse_project_text_decoration,+ resolve_project_xml_space,+)+from .drawingml.utils import (+ font_px_to_hpt,+ parse_inline_style,+ parse_project_geometry_length,+ parse_svg_length,+ split_project_text_clusters,+)+++_FONT_EXTENSIONS = frozenset({".otc", ".otf", ".ttc", ".ttf"})+_FAMILY_NAME_IDS = (16, 1, 21)+_GENERIC_FAMILIES = {+ "sans-serif": (+ "Segoe UI",+ "Arial",+ "Helvetica",+ "Noto Sans",+ "Liberation Sans",+ "DejaVu Sans",+ "Nimbus Sans",+ "Noto Sans CJK SC",+ "Source Han Sans SC",+ "Droid Sans Fallback",+ ),+ "system-ui": (+ "Segoe UI",+ "SF Pro",+ "Helvetica Neue",+ "Noto Sans",+ "Liberation Sans",+ "DejaVu Sans",+ "Noto Sans CJK SC",+ "Droid Sans Fallback",+ ),+ "serif": (+ "Times New Roman",+ "Noto Serif",+ "Liberation Serif",+ "DejaVu Serif",+ "Nimbus Roman",+ "Noto Serif CJK SC",+ "Source Han Serif SC",+ ),+ "monospace": (+ "Consolas",+ "Courier New",+ "Noto Sans Mono",+ "Liberation Mono",+ "DejaVu Sans Mono",+ "Nimbus Mono PS",+ "Noto Sans Mono CJK SC",+ ),+}+_GENERIC_FAMILIES["ui-sans-serif"] = _GENERIC_FAMILIES["system-ui"]+_GENERIC_FAMILIES["ui-serif"] = _GENERIC_FAMILIES["serif"]+_GENERIC_FAMILIES["ui-monospace"] = _GENERIC_FAMILIES["monospace"]+_UNSUPPORTED_TEXT_PROPERTIES = frozenset({+ "alignment-baseline",+ "baseline-shift",+ "direction",+ "dominant-baseline",+ "font-feature-settings",+ "font-kerning",+ "font-size-adjust",+ "font-stretch",+ "font-synthesis",+ "font-variant",+ "font-variation-settings",+ "font",+ "hyphens",+ "kerning",+ "line-height",+ "overflow-wrap",+ "text-align",+ "text-align-last",+ "text-indent",+ "text-orientation",+ "text-rendering",+ "text-transform",+ "unicode-bidi",+ "vertical-align",+ "white-space",+ "word-spacing",+ "word-break",+ "writing-mode",+})+_UNSUPPORTED_TEXT_ATTRIBUTES = frozenset({+ "dx",+ "dy",+ "lengthAdjust",+ "rotate",+ "textLength",+})+_UNSUPPORTED_BIDI_CLASSES = frozenset({+ "AL",+ "FSI",+ "LRE",+ "LRI",+ "LRO",+ "PDF",+ "PDI",+ "R",+ "RLE",+ "RLI",+ "RLO",+})+@dataclass(frozen=True)+class _FontFace:+ path: Path+ index: int+ families: tuple[str, ...]+ weight: int+ italic: bool+ weight_range: tuple[float, float] | None+ italic_range: tuple[float, float] | None+ coverage: frozenset[int]+ order: int+++@dataclass(frozen=True)+class _TextStyle:+ families: tuple[str, ...]+ font_size: float+ font_weight: int+ italic: bool+ anchor: str+ letter_spacing: float+++@dataclass(frozen=True)+class _FontRun:+ face: _FontFace+ clusters: tuple[str, ...]+ global_cluster_start: int++ @property+ def text(self) -> str:+ return "".join(self.clusters)+++@dataclass+class _ShapedRun:+ run: _FontRun+ font: Any+ infos: Sequence[Any]+ positions: Sequence[Any]+ scale: float+ advance_x: float+++@dataclass+class _DrawState:+ origin_x: float+ origin_y: float+ scale: float+ commands: list[PathCommand]+ segment_count: int = 0++ def point(self, x: float, y: float) -> tuple[float, float]:+ return (+ self.origin_x + x * self.scale,+ self.origin_y - y * self.scale,+ )+++def text_element_to_path_commands(+ element: ET.Element,+ parents: Mapping[ET.Element, ET.Element],+ *,+ font_dirs: Sequence[str | Path] = (),+) -> list[PathCommand]:+ """Return closed glyph outlines for one supported SVG ``<text>`` element."""+ chain = _element_chain(element, parents)+ _validate_text_structure(element, chain)+ text = _normalized_direct_text(element, chain)+ if not text:+ raise ValueError(f"{_element_label(element)} has no rendered text")+ if any(+ unicodedata.bidirectional(character)+ in _UNSUPPORTED_BIDI_CLASSES+ for character in text+ ):+ raise ValueError(+ f"{_element_label(element)} uses right-to-left or bidirectional "+ "text; materialize its glyph outlines before Shape Boolean"+ )++ style = _resolve_text_style(chain)+ x = _text_position(element, "x")+ y = _text_position(element, "y")+ explicit_roots = _normalize_explicit_font_dirs(font_dirs)+ catalog = _font_catalog(explicit_roots)+ candidates = _font_candidates(+ catalog,+ style.families,+ style.font_weight,+ style.italic,+ )+ if not candidates:+ family_list = ", ".join(style.families)+ raise ValueError(+ f"{_element_label(element)} cannot resolve an installed font from "+ f"{family_list!r}; add a usable fallback or pass --font-dir"+ )++ clusters = split_project_text_clusters(text)+ runs = _font_runs(+ element,+ clusters,+ candidates,+ style.families,+ )+ shaped_runs = _shape_runs(+ runs,+ style.font_size,+ style.font_weight,+ style.italic,+ style.letter_spacing,+ )+ natural_width = sum(run.advance_x for run in shaped_runs)+ tracked_width = (+ natural_width+ + max(0, len(clusters) - 1) * style.letter_spacing+ )+ if not math.isfinite(tracked_width) or tracked_width <= 0:+ raise ValueError(+ f"{_element_label(element)} resolves to a non-positive text width"+ )+ anchor_shift = {+ "start": 0.0,+ "middle": -tracked_width / 2.0,+ "end": -tracked_width,+ }[style.anchor]++ hb = _load_harfbuzz()+ draw_funcs = _draw_functions(hb)+ commands: list[PathCommand] = []+ natural_run_x = 0.0+ for shaped in shaped_runs:+ run_offsets = _cluster_offsets(shaped.run.clusters)+ glyph_cursor_x = 0.0+ glyph_cursor_y = 0.0+ for info, position in zip(shaped.infos, shaped.positions):+ if info.codepoint == 0:+ raise ValueError(+ f"{_element_label(element)} shaped a missing glyph in "+ f"{shaped.run.face.path.name}"+ )+ cluster_index = max(+ 0,+ bisect.bisect_right(run_offsets, info.cluster) - 1,+ )+ cluster_index = min(+ cluster_index,+ len(shaped.run.clusters) - 1,+ )+ global_cluster = (+ shaped.run.global_cluster_start + cluster_index+ )+ spacing_shift = global_cluster * style.letter_spacing+ state = _DrawState(+ origin_x=(+ x+ + anchor_shift+ + natural_run_x+ + glyph_cursor_x+ + position.x_offset * shaped.scale+ + spacing_shift+ ),+ origin_y=(+ y+ - glyph_cursor_y+ - position.y_offset * shaped.scale+ ),+ scale=shaped.scale,+ commands=commands,+ )+ shaped.font.draw_glyph(info.codepoint, draw_funcs, state)+ if state.segment_count == 0:+ cluster = shaped.run.clusters[cluster_index]+ if not _cluster_may_have_no_outline(cluster):+ codepoints = " ".join(+ f"U+{ord(character):04X}"+ for character in cluster+ )+ raise ValueError(+ f"{_element_label(element)} glyph for {codepoints} has "+ "no vector outline; bitmap/color-only glyphs cannot be "+ "used in Shape Boolean"+ )+ glyph_cursor_x += position.x_advance * shaped.scale+ glyph_cursor_y += position.y_advance * shaped.scale+ natural_run_x += shaped.advance_x++ if not commands:+ raise ValueError(+ f"{_element_label(element)} has no glyph outline to materialize"+ )+ return normalize_path_commands(commands)+++@lru_cache(maxsize=1)+def _load_harfbuzz() -> Any:+ try:+ import uharfbuzz+ except ImportError as exc:+ raise RuntimeError(+ "Text operands in Shape Boolean require uharfbuzz. Install the "+ "project requirements, or run: pip install uharfbuzz"+ ) from exc+ required = ("Blob", "Buffer", "DrawFuncs", "Face", "Font", "StyleTag", "shape")+ missing = [name for name in required if not hasattr(uharfbuzz, name)]+ if missing:+ raise RuntimeError(+ "Installed uharfbuzz is incompatible; missing: "+ + ", ".join(missing)+ )+ return uharfbuzz+++def _element_chain(+ element: ET.Element,+ parents: Mapping[ET.Element, ET.Element],+) -> list[ET.Element]:+ chain = [element]+ current = element+ while current in parents:+ current = parents[current]+ chain.append(current)+ chain.reverse()+ return chain+++def _validate_text_structure(+ element: ET.Element,+ chain: Sequence[ET.Element],+) -> None:+ if _local_name(element.tag) != "text":+ raise AssertionError("Text outline requires one <text> element")+ children = list(element)+ if children:+ child_tags = ", ".join(+ f"<{_local_name(child.tag)}>"+ for child in children+ )+ raise ValueError(+ f"{_element_label(element)} must contain direct single-line text; "+ f"child content is unsupported ({child_tags})"+ )+ unsupported_attrs = sorted(+ _local_name(name)+ for name in element.attrib+ if _local_name(name) in _UNSUPPORTED_TEXT_ATTRIBUTES+ )+ if unsupported_attrs:+ raise ValueError(+ f"{_element_label(element)} uses unsupported text attribute(s): "+ + ", ".join(unsupported_attrs)+ )++ for current in chain:+ inline = parse_inline_style(current.get("style"))+ unsupported = sorted(+ name+ for name in _UNSUPPORTED_TEXT_PROPERTIES+ if current.get(name) is not None or name in inline+ )+ if unsupported:+ raise ValueError(+ f"{_element_label(element)} inherits unsupported text "+ f"property/properties from {_element_label(current)}: "+ + ", ".join(unsupported)+ )++ decoration = _effective_property(chain, "text-decoration") or "none"+ try:+ parsed_decoration = parse_project_text_decoration(decoration)+ except ValueError as exc:+ raise ValueError(+ f"{_element_label(element)} text-decoration={decoration!r}: {exc}"+ ) from exc+ if parsed_decoration.canonical != "none":+ raise ValueError(+ f"{_element_label(element)} uses text decoration; materialize the "+ "decoration separately before Shape Boolean"+ )++ stroke = _effective_property(chain, "stroke")+ if stroke is not None and stroke.strip().lower() not in {+ "",+ "inherit",+ "none",+ "transparent",+ }:+ raise ValueError(+ f"{_element_label(element)} uses a visible text stroke; Shape "+ "Boolean materializes the filled glyph silhouette only"+ )+++def _normalized_direct_text(+ element: ET.Element,+ chain: Sequence[ET.Element],+) -> str:+ xml_space = "default"+ for current in chain:+ try:+ xml_space = resolve_project_xml_space(current, xml_space)+ except ValueError as exc:+ raise ValueError(+ f"{_element_label(current)} xml:space: {exc}"+ ) from exc+ segments = normalize_project_text_segments([+ (xml_space, element.text or ""),+ ])+ return "".join(text for _owner, text in segments)+++def _resolve_text_style(chain: Sequence[ET.Element]) -> _TextStyle:+ font_size = 16.0+ root_font_size = 16.0+ letter_spacing = 0.0+ family_value = "sans-serif"+ weight_value = "normal"+ style_value = "normal"+ anchor_value = "start"++ for index, current in enumerate(chain):+ inline = parse_inline_style(current.get("style"))+ raw_size = inline.get("font-size", current.get("font-size"))+ if raw_size is not None and raw_size.strip().lower() != "inherit":+ relative_base = (+ root_font_size+ if raw_size.strip().lower().endswith("rem")+ else font_size+ )+ try:+ font_size = parse_svg_length(+ raw_size,+ font_size,+ font_size=relative_base,+ )+ font_px_to_hpt(font_size)+ except ValueError as exc:+ raise ValueError(+ f"{_element_label(current)} font-size={raw_size!r}: {exc}"+ ) from exc+ if index == 0:+ root_font_size = font_size++ raw_spacing = inline.get(+ "letter-spacing",+ current.get("letter-spacing"),+ )+ if raw_spacing is not None and raw_spacing.strip().lower() != "inherit":+ try:+ letter_spacing = float(parse_project_letter_spacing(+ raw_spacing,+ font_size=font_size,+ ).value)+ except ValueError as exc:+ raise ValueError(+ f"{_element_label(current)} "+ f"letter-spacing={raw_spacing!r}: {exc}"+ ) from exc++ family_value = _updated_property(+ current,+ inline,+ "font-family",+ family_value,+ )+ weight_value = _updated_property(+ current,+ inline,+ "font-weight",+ weight_value,+ )+ style_value = _updated_property(+ current,+ inline,+ "font-style",+ style_value,+ )+ anchor_value = _updated_property(+ current,+ inline,+ "text-anchor",+ anchor_value,+ )++ families = _parse_font_family_stack(family_value)+ try:+ parsed_weight = parse_project_font_weight(weight_value)+ parsed_style = parse_project_font_style(style_value)+ parsed_anchor = parse_project_text_anchor(anchor_value)+ except ValueError as exc:+ raise ValueError(+ f"{_element_label(chain[-1])} has invalid text typography: {exc}"+ ) from exc+ weight = {+ "normal": 400,+ "bold": 700,+ }.get(parsed_weight.canonical)+ if weight is None:+ weight = int(parsed_weight.canonical)+ return _TextStyle(+ families=families,+ font_size=font_size,+ font_weight=weight,+ italic=bool(parsed_style.value),+ anchor=str(parsed_anchor.value),+ letter_spacing=letter_spacing,+ )+++def _updated_property(+ element: ET.Element,+ inline: Mapping[str, str],+ name: str,+ inherited: str,+) -> str:+ raw = inline.get(name, element.get(name))+ if raw is None or raw.strip().lower() == "inherit":+ return inherited+ value = raw.strip()+ if not value:+ raise ValueError(f"{_element_label(element)} {name} must not be empty")+ return value+++def _effective_property(+ chain: Sequence[ET.Element],+ name: str,+) -> str | None:+ value: str | None = None+ for current in chain:+ inline = parse_inline_style(current.get("style"))+ raw = inline.get(name, current.get(name))+ if raw is not None and raw.strip().lower() != "inherit":+ value = raw.strip()+ return value+++def _text_position(element: ET.Element, name: str) -> float:+ raw = element.get(name)+ if raw is None:+ return 0.0+ try:+ return parse_project_geometry_length(raw, name)+ except ValueError as exc:+ raise ValueError(+ f"{_element_label(element)} {name}={raw!r}: {exc}"+ ) from exc+++def _parse_font_family_stack(raw: str) -> tuple[str, ...]:+ families = tuple(+ value.strip().strip("'\"")+ for value in raw.split(",")+ )+ if not families or any(not family for family in families):+ raise ValueError("font-family must contain at least one family name")+ return families+++def _normalize_explicit_font_dirs(+ font_dirs: Sequence[str | Path],+) -> tuple[str, ...]:+ if isinstance(font_dirs, (str, bytes)):+ raise ValueError(+ "Shape Boolean font_dirs must be a sequence of directory paths"+ )+ roots: list[str] = []+ seen: set[str] = set()+ for raw in font_dirs:+ root = Path(raw).expanduser()+ if not root.is_dir():+ raise ValueError(f"Shape Boolean font directory not found: {root}")+ resolved = str(root.resolve())+ if resolved not in seen:+ roots.append(resolved)+ seen.add(resolved)+ return tuple(roots)+++@lru_cache(maxsize=8)+def _font_catalog(explicit_roots: tuple[str, ...]) -> tuple[_FontFace, ...]:+ hb = _load_harfbuzz()+ records: list[_FontFace] = []+ for path in _font_files(explicit_roots):+ try:+ data = path.read_bytes()+ first_face = hb.Face(data, 0)+ face_count = max(1, int(first_face.count))+ except (OSError, RuntimeError, ValueError):+ continue+ for index in range(face_count):+ try:+ face = hb.Face(data, index)+ families = _face_names(face, _FAMILY_NAME_IDS)+ if not families:+ continue+ font = hb.Font(face)+ weight_value = font.get_style_value(hb.StyleTag.WEIGHT)+ italic_value = font.get_style_value(hb.StyleTag.ITALIC)+ slant_value = font.get_style_value(hb.StyleTag.SLANT_ANGLE)+ axes = {+ axis.tag: axis+ for axis in face.axis_infos+ }+ coverage = frozenset(int(value) for value in face.unicodes)+ except (OSError, RuntimeError, TypeError, ValueError):+ continue+ weight = int(round(weight_value)) if math.isfinite(weight_value) else 400+ weight = min(1000, max(1, weight))+ italic = (+ math.isfinite(italic_value) and italic_value >= 0.5+ ) or (+ math.isfinite(slant_value) and abs(slant_value) > 0.01+ )+ records.append(_FontFace(+ path=path,+ index=index,+ families=families,+ weight=weight,+ italic=italic,+ weight_range=_axis_range(axes.get("wght")),+ italic_range=_axis_range(axes.get("ital")),+ coverage=coverage,+ order=len(records),+ ))+ if not records:+ raise RuntimeError(+ "Text operands in Shape Boolean found no readable OpenType fonts; "+ "install fonts or pass --font-dir"+ )+ return tuple(records)+++def _font_files(explicit_roots: tuple[str, ...]) -> tuple[Path, ...]:+ roots = [Path(value) for value in explicit_roots]+ roots.extend(_system_font_roots())+ files: list[Path] = []+ seen: set[str] = set()+ for root in roots:+ if not root.is_dir():+ continue+ try:+ candidates = sorted(+ (+ path+ for path in root.rglob("*")+ if path.is_file()+ and path.suffix.lower() in _FONT_EXTENSIONS+ ),+ key=lambda path: str(path).casefold(),+ )+ except OSError:+ continue+ for path in candidates:+ try:+ key = str(path.resolve())+ except OSError:+ key = str(path)+ if key not in seen:+ files.append(path)+ seen.add(key)+ return tuple(files)+++def _system_font_roots() -> tuple[Path, ...]:+ roots: list[Path] = []+ home = Path.home()+ if sys.platform.startswith("win"):+ windows = Path(os.environ.get("WINDIR", "C:/Windows"))+ roots.append(windows / "Fonts")+ local_app_data = os.environ.get("LOCALAPPDATA")+ if local_app_data:+ roots.append(Path(local_app_data) / "Microsoft/Windows/Fonts")+ elif sys.platform == "darwin":+ roots.extend((+ Path("/System/Library/Fonts"),+ Path("/Library/Fonts"),+ home / "Library/Fonts",+ ))+ else:+ xdg_data_home = os.environ.get("XDG_DATA_HOME")+ if xdg_data_home:+ roots.append(Path(xdg_data_home) / "fonts")+ roots.extend((home / ".local/share/fonts", home / ".fonts"))+ xdg_data_dirs = os.environ.get(+ "XDG_DATA_DIRS",+ "/usr/local/share:/usr/share",+ )+ roots.extend(+ Path(value) / "fonts"+ for value in xdg_data_dirs.split(os.pathsep)+ if value+ )+ return tuple(roots)+++def _face_names(face: Any, name_ids: Sequence[int]) -> tuple[str, ...]:+ values: list[str] = []+ seen: set[str] = set()+ for name_id in name_ids:+ value = face.get_name(name_id)+ if not value:+ continue+ normalized = " ".join(str(value).split())+ key = _family_key(normalized)+ if normalized and key not in seen:+ values.append(normalized)+ seen.add(key)+ return tuple(values)+++def _font_candidates(+ catalog: Sequence[_FontFace],+ families: Sequence[str],+ target_weight: int,+ italic: bool,+) -> list[_FontFace]:+ by_family: dict[str, list[_FontFace]] = {}+ for face in catalog:+ for family in face.families:+ by_family.setdefault(_family_key(family), []).append(face)++ candidates: list[_FontFace] = []+ seen: set[tuple[Path, int]] = set()+ for requested in families:+ requested_key = _family_key(requested)+ generic = requested_key in _GENERIC_FAMILIES+ expanded = _GENERIC_FAMILIES.get(requested_key, (requested,))+ for family in expanded:+ available = by_family.get(_family_key(family), ())+ if generic:+ available = tuple(+ face+ for face in available+ if _face_supports_style(+ face,+ target_weight,+ italic,+ )+ )+ matches = sorted(+ available,+ key=lambda face: (+ not _face_supports_style(+ face,+ target_weight,+ italic,+ ),+ face.italic != italic,+ abs(face.weight - target_weight),+ face.order,+ ),+ )+ for face in matches:+ key = (face.path, face.index)+ if key not in seen:+ candidates.append(face)+ seen.add(key)+ return candidates+++def _face_supports_style(+ face: _FontFace,+ requested_weight: int,+ requested_italic: bool,+) -> bool:+ weight_supported = (+ face.weight == requested_weight+ or (+ face.weight_range is not None+ and face.weight_range[0]+ <= requested_weight+ <= face.weight_range[1]+ )+ )+ italic_value = 1.0 if requested_italic else 0.0+ italic_supported = (+ face.italic == requested_italic+ or (+ face.italic_range is not None+ and face.italic_range[0]+ <= italic_value+ <= face.italic_range[1]+ )+ )+ return weight_supported and italic_supported+++def _axis_range(axis: Any | None) -> tuple[float, float] | None:+ if axis is None:+ return None+ return (float(axis.min_value), float(axis.max_value))+++def _font_runs(+ element: ET.Element,+ clusters: Sequence[str],+ candidates: Sequence[_FontFace],+ families: Sequence[str],+) -> list[_FontRun]:+ selected: list[tuple[str, _FontFace]] = []+ previous_face: _FontFace | None = None+ for cluster in clusters:+ required = _required_codepoints(cluster)+ face = next(+ (+ candidate+ for candidate in candidates+ if required.issubset(candidate.coverage)+ ),+ None,+ )+ if face is None and not required and previous_face is not None:+ face = previous_face+ if face is None:+ codepoints = " ".join(+ f"U+{ord(character):04X}"+ for character in cluster+ )+ raise ValueError(+ f"{_element_label(element)} cannot resolve glyphs for "+ f"{codepoints} from font stack {', '.join(families)!r}"+ )+ selected.append((cluster, face))+ previous_face = face++ runs: list[_FontRun] = []+ run_clusters: list[str] = []+ run_face: _FontFace | None = None+ run_start = 0+ for index, (cluster, face) in enumerate(selected):+ if run_face is None or face is run_face:+ run_clusters.append(cluster)+ run_face = face+ continue+ runs.append(_FontRun(+ face=run_face,+ clusters=tuple(run_clusters),+ global_cluster_start=run_start,+ ))+ run_clusters = [cluster]+ run_face = face+ run_start = index+ if run_face is not None:+ runs.append(_FontRun(+ face=run_face,+ clusters=tuple(run_clusters),+ global_cluster_start=run_start,+ ))+ return runs+++def _shape_runs(+ runs: Sequence[_FontRun],+ font_size: float,+ font_weight: int,+ italic: bool,+ letter_spacing: float,+) -> list[_ShapedRun]:+ hb = _load_harfbuzz()+ font_cache: dict[tuple[Path, int], tuple[Any, int]] = {}+ shaped: list[_ShapedRun] = []+ for run in runs:+ key = (run.face.path, run.face.index)+ cached = font_cache.get(key)+ if cached is None:+ data = run.face.path.read_bytes()+ face = hb.Face(data, run.face.index)+ upem = int(face.upem)+ if upem <= 0:+ raise ValueError(+ f"Font {run.face.path} face {run.face.index} has invalid UPEM"+ )+ font = hb.Font(face)+ font.scale = (upem, upem)+ _apply_font_style(+ run.face,+ face,+ font,+ font_weight,+ italic,+ )+ cached = (font, upem)+ font_cache[key] = cached+ font, upem = cached+ buffer = hb.Buffer()+ buffer.add_str(run.text)+ buffer.guess_segment_properties()+ if str(buffer.direction) != "ltr":+ raise ValueError(+ f"Text run {run.text!r} resolves to {buffer.direction} "+ "direction; only horizontal left-to-right text is supported"+ )+ if letter_spacing:+ hb.shape(font, buffer, {"liga": False, "clig": False})+ else:+ hb.shape(font, buffer)+ infos = tuple(buffer.glyph_infos)+ positions = tuple(buffer.glyph_positions)+ if not infos or len(infos) != len(positions):+ raise ValueError(f"Font shaping produced no glyphs for {run.text!r}")+ scale = font_size / upem+ advance_x = sum(position.x_advance for position in positions) * scale+ shaped.append(_ShapedRun(+ run=run,+ font=font,+ infos=infos,+ positions=positions,+ scale=scale,+ advance_x=advance_x,+ ))+ return shaped+++def _apply_font_style(+ record: _FontFace,+ face: Any,+ font: Any,+ requested_weight: int,+ requested_italic: bool,+) -> None:+ axes = {+ axis.tag: axis+ for axis in face.axis_infos+ }+ variations: dict[str, float] = {}+ weight_axis = axes.get("wght")+ if weight_axis is not None:+ if not weight_axis.min_value <= requested_weight <= weight_axis.max_value:+ raise ValueError(+ f"Font {record.path.name} cannot provide requested weight "+ f"{requested_weight}; its wght axis is "+ f"{weight_axis.min_value:g}..{weight_axis.max_value:g}"+ )+ variations["wght"] = float(requested_weight)+ elif record.weight != requested_weight:+ raise ValueError(+ f"Font {record.path.name} resolves weight {record.weight}, not "+ f"requested {requested_weight}; install the exact face, choose a "+ "matching family, or adjust the text operand"+ )++ italic_axis = axes.get("ital")+ italic_value = 1.0 if requested_italic else 0.0+ if italic_axis is not None:+ if not italic_axis.min_value <= italic_value <= italic_axis.max_value:+ style = "italic" if requested_italic else "normal"+ raise ValueError(+ f"Font {record.path.name} cannot provide requested {style} "+ "style through its ital axis"+ )+ variations["ital"] = italic_value+ elif record.italic != requested_italic:+ requested = "italic" if requested_italic else "normal"+ resolved = "italic" if record.italic else "normal"+ raise ValueError(+ f"Font {record.path.name} resolves {resolved}, not requested "+ f"{requested}; install the exact face, choose a matching family, "+ "or adjust the text operand"+ )++ if variations:+ font.set_variations(variations)+++def _draw_functions(hb: Any) -> Any:+ functions = hb.DrawFuncs()++ def move_to(x: float, y: float, state: _DrawState) -> None:+ point = state.point(x, y)+ state.commands.append(PathCommand("M", [*point]))++ def line_to(x: float, y: float, state: _DrawState) -> None:+ point = state.point(x, y)+ state.commands.append(PathCommand("L", [*point]))+ state.segment_count += 1++ def quadratic_to(+ control_x: float,+ control_y: float,+ x: float,+ y: float,+ state: _DrawState,+ ) -> None:+ control = state.point(control_x, control_y)+ point = state.point(x, y)+ state.commands.append(PathCommand(+ "Q",+ [control[0], control[1], point[0], point[1]],+ ))+ state.segment_count += 1++ def cubic_to(+ control_1_x: float,+ control_1_y: float,+ control_2_x: float,+ control_2_y: float,+ x: float,+ y: float,+ state: _DrawState,+ ) -> None:+ control_1 = state.point(control_1_x, control_1_y)+ control_2 = state.point(control_2_x, control_2_y)+ point = state.point(x, y)+ state.commands.append(PathCommand(+ "C",+ [+ control_1[0],+ control_1[1],+ control_2[0],+ control_2[1],+ point[0],+ point[1],+ ],+ ))+ state.segment_count += 1++ def close_path(state: _DrawState) -> None:+ state.commands.append(PathCommand("Z", []))++ functions.set_move_to_func(move_to)+ functions.set_line_to_func(line_to)+ functions.set_quadratic_to_func(quadratic_to)+ functions.set_cubic_to_func(cubic_to)+ functions.set_close_path_func(close_path)+ return functions+++def _cluster_offsets(clusters: Sequence[str]) -> list[int]:+ offsets: list[int] = []+ offset = 0+ for cluster in clusters:+ offsets.append(offset)+ offset += len(cluster)+ return offsets+++def _required_codepoints(cluster: str) -> frozenset[int]:+ return frozenset(+ ord(character)+ for character in cluster+ if not _is_default_ignorable(character)+ )+++def _is_default_ignorable(character: str) -> bool:+ codepoint = ord(character)+ return (+ unicodedata.category(character) == "Cf"+ or 0x180B <= codepoint <= 0x180D+ or 0x2061 <= codepoint <= 0x206F+ or 0xFE00 <= codepoint <= 0xFE0F+ or 0xE0100 <= codepoint <= 0xE01EF+ )+++def _cluster_may_have_no_outline(cluster: str) -> bool:+ return all(+ character.isspace() or _is_default_ignorable(character)+ for character in cluster+ )+++def _family_key(value: str) -> str:+ return " ".join(value.split()).casefold()+++def _local_name(tag: object) -> str:+ raw = str(tag)+ return raw.rsplit("}", 1)[-1] if "}" in raw else raw+++def _element_label(element: ET.Element) -> str:+ tag = _local_name(element.tag)+ element_id = element.get("id")+ return f"<{tag} id={element_id!r}>" if element_id else f"<{tag}>"diff --git a/skills/ppt-master/workflows/create-template.md b/skills/ppt-master/workflows/create-template.mdindex 3cdc1f7c..a975a9e4 100644--- a/skills/ppt-master/workflows/create-template.md+++ b/skills/ppt-master/workflows/create-template.md@@ -550,7 +550,7 @@ paint comes from the confirmed brief and template `design_spec.md`. Afterinserting the complete helper group, add only the registered structuralattributes required by its Master/Layout or object-slot role; geometry andpaint changes require a new helper render. When actual `standard` / `fidelity`-construction needs a Boolean result over closed shapes, Template_Designer+construction needs a Boolean result over supported shape/text operands, Template_Designerdecides whether to use `shape_boolean_svg.py` under[`native-shape-authoring.md`](../references/native-shape-authoring.md) §6; abrief/reference suggestion does not lock the operation. `mirror` preserves the expandeddiff --git a/skills/ppt-master/workflows/generate-pptx.md b/skills/ppt-master/workflows/generate-pptx.mdindex c9fa2ff2..17165d7e 100644--- a/skills/ppt-master/workflows/generate-pptx.md+++ b/skills/ppt-master/workflows/generate-pptx.md@@ -387,7 +387,7 @@ Read references/visual-styles/<resolved-id>.md # one preset id, or each `visu| `spec_lock.md images` / §VIII has an image/formula row, or the template has bundled images | `executor-image.md` + `image-layout-spec.md` + `svg-image-embedding.md`; add `image-layout-patterns.md` only for a cited `#<id>` or optional composition recall || At least one placed image has `Status: Sourced` | `executor-web-image.md` after the image branch || The locked style/current page calls for noncanonical or alpha paint, dash/cap/join, tracking/decoration/outline, gradient/filter/glow/shadow, path/transform/clipping, or another constructed effect | `svg-effects.md` before authoring that value or effect |-| §IX contains `Native shape suggestion`, or current page construction calls for a literal PowerPoint stock shape, a stock Connector contour, an explicit Merge Shapes operation or result, or a shape-built dimensional form (cylinder/pedestal, layered diagram, reflection, ground plane), or Executor is about to hand-author a freeform not already required by data geometry or the locked organic / hand-drawn style | `native-shape-authoring.md` before selecting or materializing that geometry. This trigger is image-independent: a text-only, data-only, or icon-only page reaches it the same way |+| §IX contains `Native shape suggestion`, or current page construction calls for a literal PowerPoint stock shape, a stock Connector contour, an explicit Merge Shapes operation/result (including a text, letterform, or numeral knockout), or a shape-built dimensional form (cylinder/pedestal, layered diagram, reflection, ground plane), or Executor is about to hand-author a freeform not already required by data geometry or the locked organic / hand-drawn style | `native-shape-authoring.md` before selecting or materializing that geometry. This trigger is image-independent: a text-only, data-only, or icon-only page reaches it the same way || All SVG pages and SVG quality gates are complete, and the effective Speaker Notes outcome in `design_spec.md §I` is enabled | `executor-notes.md` before generating speaker notes |No branch is loaded by analogy. Evaluate these triggers from `spec_lock.md`, §VII/§VIII, the selected style, and the current page plan.diff --git a/skills/ppt-master/workflows/profiles/quick-generate.md b/skills/ppt-master/workflows/profiles/quick-generate.mdindex 131905c7..6d65a20f 100644--- a/skills/ppt-master/workflows/profiles/quick-generate.md+++ b/skills/ppt-master/workflows/profiles/quick-generate.md@@ -104,8 +104,9 @@ silently replace it with unrelated material.Always read[`shared-standards-core.md`](../../references/shared-standards-core.md). Do notload `executor-base.md`: its persisted-plan prerequisites do not apply to this-profile. Load the conditional image/web/canvas references only when the-resolved SVG or selected capability needs them.+profile. Load the conditional image/web/canvas references when needed, and load+`native-shape-authoring.md` for selected preset/Boolean construction such as+text knockouts.Use one zero-padded filename width sized for the resolved roster, such as`01_cover.svg` through `12_end.svg` or `001_cover.svg` through `120_end.svg`.