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
fix(checker): validate exported PPTX typefaces instead of the stack tail
hugohe3776373864d2a
diff --git a/skills/ppt-master/references/executor-base.md b/skills/ppt-master/references/executor-base.mdindex 20cb2a65..b2fdf6fa 100644--- a/skills/ppt-master/references/executor-base.md+++ b/skills/ppt-master/references/executor-base.md@@ -392,7 +392,7 @@ Source of truth: `spec_lock.md typography`. Use `font_family` as default; overriIf `spec_lock.md` is absent, consult [`strategist.md`](strategist.md) §g — do not invent a stack.-**Hard rule**: every SVG `font-family` stack MUST end with a pre-installed family (Microsoft YaHei / SimHei / SimSun / Arial / Calibri / Segoe UI / Times New Roman / Georgia / Consolas / Courier New / Impact / Arial Black). PPTX has no runtime fallback — missing fonts degrade to Calibri.+**Hard rule**: every SVG `font-family` stack MUST resolve to pre-installed exported Latin / EA typefaces (Microsoft YaHei / SimHei / SimSun / Arial / Calibri / Segoe UI / Times New Roman / Georgia / Consolas / Courier New / Impact / Arial Black). PPTX has no runtime fallback — missing fonts degrade to Calibri.---diff --git a/skills/ppt-master/references/shared-standards.md b/skills/ppt-master/references/shared-standards.mdindex 25ac5dff..ecc3babf 100644--- a/skills/ppt-master/references/shared-standards.md+++ b/skills/ppt-master/references/shared-standards.md@@ -172,7 +172,7 @@ One offending character invalidates the file and aborts export. Numeric refs (`&- **viewBox** MUST match the canvas dimensions; it is the single source of truth for canvas size. Root `width`/`height` are optional compatibility attributes and are not used as PPT Master canvas authority.- **Background**: Use `<rect>` to define the page background color- **`<tspan>`** has two purposes: (1) manual line breaks (use `dy` or explicit `y`); (2) inline run formatting on the same line (color/weight/size). `<foreignObject>` is FORBIDDEN. See "Single logical line" rule below.-- **Fonts**: every `font-family` stack MUST end with a pre-installed family (Microsoft YaHei / SimSun / Arial / Times New Roman / Consolas …); `@font-face` is FORBIDDEN. Full rule: [`strategist.md §g`](strategist.md).+- **Fonts**: every `font-family` stack MUST resolve to pre-installed exported Latin / EA typefaces (Microsoft YaHei / SimSun / Arial / Times New Roman / Consolas …); `@font-face` is FORBIDDEN. Full rule: [`strategist.md §g`](strategist.md).- **Styles**: inline only (`fill=""`, `font-size=""`); `<style>`/`class` FORBIDDEN (`id` inside `<defs>` is fine)- **Colors**: HEX only; transparency via `fill-opacity`/`stroke-opacity`- **Images**: `<image href="../images/xxx.png" preserveAspectRatio="xMidYMid slice"/>`diff --git a/skills/ppt-master/references/strategist.md b/skills/ppt-master/references/strategist.mdindex 11794c06..a550cab1 100644--- a/skills/ppt-master/references/strategist.md+++ b/skills/ppt-master/references/strategist.md@@ -173,16 +173,16 @@ See [`../templates/icons/README.md`](../templates/icons/README.md) for the curre#### Font Combinations-> Same-deck fonts must form **contrast** (different family, weight, or proportion) or **concord** (one family throughout). "Similar but not identical" pairings *across roles* are forbidden — see blacklist below. *Within one stack*, pairing a Windows font with a macOS counterpart (e.g. `Microsoft YaHei` + `PingFang SC`) is encouraged as a browser-preview nicety; converter writes only the first into PPTX.+> Same-deck fonts must form **contrast** (different family, weight, or proportion) or **concord** (one family throughout). "Similar but not identical" pairings *across roles* are forbidden — see blacklist below. *Within one stack*, pairing a Windows font with a macOS counterpart (e.g. `Microsoft YaHei` + `PingFang SC`) is a browser-preview nicety; converter writes resolved Latin / EA typefaces into PPTX, not the CSS fallback tail.-> **⚠️ PPT-safe font discipline (HARD rule).** PPTX has no runtime fallback — missing fonts substitute to Calibri. Every stack MUST end with a pre-installed font:+> **⚠️ PPT-safe font discipline (HARD rule).** PPTX has no runtime fallback — missing fonts substitute to Calibri. Each stack's exported Latin / EA typefaces MUST resolve to pre-installed fonts:> - CJK → `"Microsoft YaHei"` / `SimHei` / `SimSun` / `FangSong` / `KaiTi`> - Latin sans → `Arial` / `Calibri` / `Segoe UI` / `Verdana` / `Trebuchet MS`> - Latin serif → `"Times New Roman"` / `Georgia` / `Cambria` / `Palatino` / `Garamond`> - Mono → `Consolas` / `"Courier New"`> - Display → `Impact` / `"Arial Black"`>-> Stacks led by non-pre-installed fonts (Inter / HarmonyOS Sans / Source Han / brand typefaces like McKinsey Bower) are only acceptable when the Design Spec notes "requires install or PPTX embed".+> Stacks that export non-pre-installed typefaces (Inter / HarmonyOS Sans / Source Han / brand typefaces like McKinsey Bower) are only acceptable when the Design Spec notes "requires install or PPTX embed".**Forbidden — similar-but-not-identical pairings across roles** (do not split title vs body across these; within one stack as cross-platform fallback they remain encouraged):@@ -222,7 +222,7 @@ See [`../templates/icons/README.md`](../templates/icons/README.md) for the curre| Tech / developer | `Arial, "Microsoft YaHei", sans-serif` | same | `Consolas, "Courier New", monospace` || Concord (single family — pick the family by subject + `visual_style`) | `<family by subject>, …, sans-serif / serif` | same | — |-> **Stack length discipline (soft rule).** ≤4 fonts per stack. The **first** CJK and first Latin font MUST be pre-installed — the converter writes only those, and a non-installed lead substitutes to Calibri ([`drawingml_utils.py parse_font_family`](../scripts/svg_to_pptx/drawingml_utils.py)). Choose that lead from the safe set **by the locked style's character**: `Microsoft YaHei` / `Arial` are the *neutral* members — perfect as the tail fallback and as the lead only when the style is plain-sans, but **not the automatic lead for every deck**. For a styled title, lead with `SimHei` / `KaiTi` / `FangSong` / `SimSun` / `Georgia` / `Cambria` / `Impact` / `Consolas` as the character asks. Keep at most **one** macOS-exclusive family (typically `"PingFang SC"`); macOS→Windows fallback is auto-mapped via `FONT_FALLBACK_WIN`.+> **Stack length discipline (soft rule).** ≤4 fonts per stack. The exported CJK / Latin typefaces MUST be pre-installed after converter resolution ([`drawingml_utils.py parse_font_family`](../scripts/svg_to_pptx/drawingml_utils.py)). Choose those exported faces from the safe set **by the locked style's character**: `Microsoft YaHei` / `Arial` are the *neutral* members — perfect as the tail fallback and as the lead only when the style is plain-sans, but **not the automatic lead for every deck**. For a styled title, lead with `SimHei` / `KaiTi` / `FangSong` / `SimSun` / `Georgia` / `Cambria` / `Impact` / `Consolas` as the character asks. Keep at most **one** macOS-exclusive family (typically `"PingFang SC"`); macOS→Windows fallback is auto-mapped via `FONT_FALLBACK_WIN`.> **Non-pre-installed directions** (require install or PPTX embed; note the constraint in Design Spec):> - **Retro / pixel** — Press Start 2P / VT323 / Silkscreendiff --git a/skills/ppt-master/scripts/error_helper.py b/skills/ppt-master/scripts/error_helper.pyindex b04560a7..18462aa1 100644--- a/skills/ppt-master/scripts/error_helper.py+++ b/skills/ppt-master/scripts/error_helper.py@@ -266,7 +266,7 @@ class ErrorHelper:'message': 'Forbidden web font (@font-face) detected','solutions': ['Remove @font-face declarations',- 'End every font-family stack with a PPT-safe pre-installed family',+ 'Use font-family stacks that export PPT-safe pre-installed typefaces','Example: font-family: "Microsoft YaHei", Arial, sans-serif'],'severity': 'error'@@ -290,9 +290,9 @@ class ErrorHelper:'severity': 'error'},'invalid_font': {- 'message': 'Font stack does not end on a PPT-safe family',+ 'message': 'Font stack exports non-PPT-safe typefaces to PPTX','solutions': [- 'End the stack with a cross-platform pre-installed family',+ 'Use stacks whose exported Latin / EA typefaces are pre-installed','CJK: "Microsoft YaHei", sans-serif | SimSun, serif','Latin: Arial, sans-serif | "Times New Roman", serif','Mono: Consolas, "Courier New", monospace',diff --git a/skills/ppt-master/scripts/svg_quality_checker.py b/skills/ppt-master/scripts/svg_quality_checker.pyindex 90a36ff7..8e51ee74 100644--- a/skills/ppt-master/scripts/svg_quality_checker.py+++ b/skills/ppt-master/scripts/svg_quality_checker.py@@ -45,6 +45,13 @@ except ImportError:_load_animation_config = None_validate_animation_config = None+try:+ from svg_to_pptx.drawingml_utils import (+ parse_font_family as _parse_export_font_family,+ )+except ImportError:+ _parse_export_font_family = None+try:from svg_to_pptx.native_objects import (validate_native_object_marker as _validate_native_object_marker,@@ -70,6 +77,21 @@ except ImportError:HEX_VALUE_RE = re.compile(r"#[0-9A-Fa-f]{3,8}")SVG_NS = "http://www.w3.org/2000/svg"+# Fonts that survive direct PPTX typeface assignment on a typical Windows /+# macOS viewer without requiring a custom install. Keep this aligned with+# strategist.md §g and drawingml_utils.FONT_FALLBACK_WIN.+PPT_SAFE_FONTS = {+ 'microsoft yahei', 'simhei', 'simsun', 'kaiti', 'fangsong',+ 'dengxian', 'microsoft jhenghei',+ 'pingfang sc', 'heiti sc', 'songti sc', 'stsong',+ 'arial', 'arial black', 'calibri', 'segoe ui', 'verdana',+ 'helvetica', 'helvetica neue', 'tahoma', 'trebuchet ms',+ 'times new roman', 'times', 'georgia', 'cambria', 'palatino',+ 'garamond', 'book antiqua',+ 'consolas', 'courier new', 'menlo', 'monaco',+ 'impact',+}+# Ramp envelope for font-size drift detection.# From design_spec_reference.md §IV — Font Size Hierarchy: the ramp spans# from page-number floor (0.5x body) to cover-title ceiling (5.0x body).@@ -518,51 +540,53 @@ class SVGQualityChecker:def _check_fonts(self, content: str, result: Dict):"""Check font usage.- PPTX stores a single `typeface` per run with no runtime fallback, so every- stack must END with a cross-platform pre-installed family. See- strategist.md §g "PPT-safe font discipline".+ PPTX stores concrete typefaces per run with no CSS fallback. The+ converter resolves each SVG font stack to exported latin / EA typefaces;+ validate those exported values rather than the visual-preview tail."""- font_matches = re.findall(- r'font-family[:\s]*["\']([^"\']+)["\']', content, re.IGNORECASE)+ font_matches = self._font_family_values(content)if not font_matches:return- result['info']['fonts'] = list(set(font_matches))-- # Pre-installed on Windows + macOS out of the box (plus their direct- # FONT_FALLBACK_WIN mappings). A stack whose last concrete family is in- # this set survives the PPTX round-trip on any viewer machine.- ppt_safe_tail = {- 'microsoft yahei', 'simhei', 'simsun', 'kaiti', 'fangsong',- 'dengxian', 'microsoft jhenghei',- 'pingfang sc', 'heiti sc', 'songti sc', 'stsong',- 'arial', 'arial black', 'calibri', 'segoe ui', 'verdana',- 'helvetica', 'helvetica neue', 'tahoma', 'trebuchet ms',- 'times new roman', 'times', 'georgia', 'cambria', 'palatino',- 'consolas', 'courier new', 'menlo', 'monaco',- 'impact',- }+ result['info']['fonts'] = sorted(set(font_matches))+ if _parse_export_font_family is None:+ result['warnings'].append(+ "Unable to import svg_to_pptx font resolver; skipped exported-font safety check"+ )+ returnfor font_family in font_matches:- # Drop the generic CSS fallback (sans-serif / serif / monospace)- # and inspect the last concrete family.- parts = [p.strip().strip('"').strip("'").lower()- for p in font_family.split(',')]- parts = [p for p in parts- if p and p not in ('sans-serif', 'serif', 'monospace',- 'cursive', 'fantasy', 'system-ui')]- if not parts:- continue- tail = parts[-1]- if tail not in ppt_safe_tail:+ exported = _parse_export_font_family(font_family)+ unsafe = [+ f"{role}={family}"+ for role, family in exported.items()+ if family.strip().lower() not in PPT_SAFE_FONTS+ ]+ if unsafe:result['warnings'].append(- f"Font stack does not end on a PPT-safe family "- f"(expected e.g. Microsoft YaHei / SimSun / Arial / "- f"Times New Roman / Consolas): {font_family}"+ "Font stack exports non-PPT-safe typeface(s) to PPTX "+ f"({', '.join(unsafe)}): {font_family}")break+ @staticmethod+ def _font_family_values(content: str) -> List[str]:+ """Extract SVG font-family values from attributes and inline styles."""+ values: List[str] = []+ for match in re.finditer(r'\bfont-family\s*=\s*(["\'])(.*?)\1', content, re.IGNORECASE):+ values.append(html.unescape(match.group(2)).strip())++ for match in re.finditer(r'\bstyle\s*=\s*(["\'])(.*?)\1', content, re.IGNORECASE | re.DOTALL):+ style_value = html.unescape(match.group(2))+ for part in style_value.split(';'):+ if ':' not in part:+ continue+ name, value = part.split(':', 1)+ if name.strip().lower() == 'font-family':+ values.append(value.strip())+ return [value for value in values if value]+def _check_text_elements(self, content: str, result: Dict):"""Check text elements and wrapping methods"""# Count text and tspan elements@@ -1906,7 +1930,7 @@ class SVGQualityChecker:print(f" 1. XML well-formedness: write typography as raw Unicode (—, ©, →, NBSP); escape XML reserved chars as & < > " ' — never use HTML named entities like — ©")print(f" 2. viewBox issues: Ensure consistency with canvas format (see references/canvas-formats.md)")print(f" 3. foreignObject: Use <text> + <tspan> for manual line breaks")- print(f" 4. Font issues: end every font-family stack with a PPT-safe family (e.g. Microsoft YaHei / Arial / Consolas)")+ print(f" 4. Font issues: use PPT-safe exported typefaces (e.g. Microsoft YaHei / Arial / Consolas)")def _print_animation_summary(self):"""Print animations.json validation issues if present."""