Skip to content

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(text_measure): calibrate a role at bold weight; name the export-side downsize and the grid-line inset

hugohe3a0d4af8ee4ba
diff --git a/skills/ppt-master/references/image-generator.md b/skills/ppt-master/references/image-generator.md
index b62eb490..6e47d678 100644
--- a/skills/ppt-master/references/image-generator.md
+++ b/skills/ppt-master/references/image-generator.md
@@ -126,7 +126,7 @@ A sheet generates compatible transparent **illustration**, **illustrated-icon**,
**Sheet prompt convention** — one `page_role: local` item with `image_size` from final placement; spot sheets `text_policy: none`, lettering sheets `embedded`:
- **Grid**: derive `aspect_ratio` and `--grid` from the target shape, not a universal square grid. State an invisible logical **R×C grid** and the cell shape (compact square object, tall portrait, wide vignette, wide lettering mark); center each element in about 65% of its cell and keep at least 10% key-only margin on every side — tips, steam, particles, and effects included — so `slice_images.py --strict-alpha` never meets content on a cell edge. Never draw cells, panels, dividers, borders, frames, or alternate gutter colors; never shrink every subject into a square sticker.
-- **Key**: one flat chroma key across the sheet — pure `#00FF00`, `#0000FF`, or `#FF0000`, chosen so its hue is absent from every element and effect (a pure key despills and recovers soft alpha; an opaque element of the key's hue keeps its color, but thin dark strokes of that hue still fringe; on a dark deck the despilled fringe takes the key's complementary hue — white chalk keyed on pure blue leaves a yellow-green halo on slate — so key those sheets with the measured ground colour, which skips despill) — stated as exact HEX before the palette and the subjects (deck colors appear only inside elements), unchanged in every gutter, free of reflections or spill; grain, halftone, and vignette stay inside elements. The key is technical, not deck palette. Every pixel that is not an element is the key itself — no white card, panel, paper, mat, or frame under an element and no second tint of the key; state the key rule first in the prompt and repeat it last, because a model told only "no borders" still paints each element on a white card.
+- **Key**: one flat chroma key across the sheet — pure `#00FF00`, `#0000FF`, or `#FF0000`, chosen so its hue is absent from every element and effect (a pure key despills and recovers soft alpha; an opaque element of the key's hue keeps its color, but thin dark strokes of that hue still fringe; on a dark deck the despilled fringe takes the key's complementary hue — white chalk keyed on pure blue leaves a yellow-green halo on slate — so plan two runs for them: slice with the pure key first, then rerun with the measured ground colour `--strict-alpha` names, which skips despill) — stated as exact HEX before the palette and the subjects (deck colors appear only inside elements), unchanged in every gutter, free of reflections or spill; grain, halftone, and vignette stay inside elements. The key is technical, not deck palette. Every pixel that is not an element is the key itself — no white card, panel, paper, mat, or frame under an element and no second tint of the key; state the key rule first in the prompt and repeat it last, because a model told only "no borders" still paints each element on a white card.
- **Identity**: shared `deck_rendering` + `color_scheme`.
- **Illustration / illustrated-icon sheet**: name each element and its page or reuse job; for an icon, the compact cue that must survive at placement size; the §5.3 `none` cue.
- **Lettering sheet**: exactly one named stable string per cell as the only text, quoted literally; the group's letterform character and treatment, then role, placement/background relationship, relative weight, and energy under §5.3's controlled-authorship default; artistry glyph-bound (silhouette, stroke structure, material, texture, depth, contour-bound light). No topic motifs, scene fragments, icons, detached ribbons, or particles unless the approved treatment is a lettering-plus-illustration lockup; key-only padding, no scene, unrelated copy, labels, watermark, or mockup surface. A single mark on a wide sheet (3:2 or wider) tends to come back with a faded ghost copy of itself above or below the real mark — give a lone mark a narrow band (about 4:1) that leaves no room for a second line, and inspect every lettering slice for a ghost band, not only for the characters.
diff --git a/skills/ppt-master/references/svg-effects.md b/skills/ppt-master/references/svg-effects.md
index e77f5962..2e2a3a35 100644
--- a/skills/ppt-master/references/svg-effects.md
+++ b/skills/ppt-master/references/svg-effects.md
@@ -255,7 +255,11 @@ alone. A clip disables `meet` frame-fit, so match the box to the source ratio
or use `slice`; put a §6.4 filter directly on an unclipped image, and for a
clipped one on an exact outer `<g>` whose sole visual child is that image —
never both on the same `<image>`. A nested `<svg>` is only the exact
-single-image crop wrapper the crop parser accepts, not a general viewport.
+single-image crop wrapper the crop parser accepts, not a general viewport;
+its required form (outer `preserveAspectRatio="none"` + `overflow="hidden"`
++ unit-space `viewBox`, child `<image>` at `0 0 1 1`) is in
+[`svg-contract.md`](../scripts/docs/svg-contract.md) under "Nested SVG is
+picture-crop transport".
| Overlay | Construction | Typical stops / alpha |
|---|---|---|
diff --git a/skills/ppt-master/scripts/docs/svg-pipeline.md b/skills/ppt-master/scripts/docs/svg-pipeline.md
index a35bc492..d1090f5a 100644
--- a/skills/ppt-master/scripts/docs/svg-pipeline.md
+++ b/skills/ppt-master/scripts/docs/svg-pipeline.md
@@ -1027,7 +1027,7 @@ class-average estimate, with the existing fixed advances for monospaced faces.
- `box` prints a `data-pptx-bounds` attribute plus numeric `top` and `bottom`, or
a JSON bounds object with `--json`.
- `calibrate` measures fixed CJK and Latin samples for every typography role
- from `spec_lock.md` or repeatable `--role NAME:FAMILY:SIZE` overrides, writes
+ from `spec_lock.md` or repeatable `--role NAME:FAMILY:SIZE[:bold]` overrides, writes
`validation/text_calibration.json`, and prints a compact table or JSON. The
estimator is additive across scripts, so a line mixing CJK with Latin words
or digits is estimated as (CJK chars ÷ CJK rate + other chars ÷ Latin rate)
diff --git a/skills/ppt-master/scripts/slice_images.py b/skills/ppt-master/scripts/slice_images.py
index 9d565c9a..979b8786 100644
--- a/skills/ppt-master/scripts/slice_images.py
+++ b/skills/ppt-master/scripts/slice_images.py
@@ -684,7 +684,8 @@ def _log_keying_findings(
_log(" inside its cell with a clear key-only gutter, or rerun with an "
"explicit")
_log(" --bg <hex> and a larger --tolerance; use --inset when a drawn "
- "outer gutter is isolated from every element.")
+ "outer gutter is isolated from every element, or when the model drew "
+ "grid lines between cells (--inset 0.02, or H,V for wide cells).")
if sheet_border is not None:
dominant, drift, outlier = sheet_border
hex_bg = "#{:02X}{:02X}{:02X}".format(*dominant)
diff --git a/skills/ppt-master/scripts/svg_quality/checker.py b/skills/ppt-master/scripts/svg_quality/checker.py
index 3675b14d..9606c699 100644
--- a/skills/ppt-master/scripts/svg_quality/checker.py
+++ b/skills/ppt-master/scripts/svg_quality/checker.py
@@ -4905,7 +4905,9 @@ class SVGQualityChecker:
f"{int(display_w)}x{int(display_h)} {fit_label} frame; "
f"the source is {source_mib:.1f} MiB — file-size "
"advisory only, not an aspect-ratio warning; consider "
- "a smaller source asset"
+ "a smaller source asset, or export with "
+ "svg_to_pptx.py --image-sizing display to downsize "
+ "at export time"
)
except ImportError:
pass # PIL not available, skip resolution check
diff --git a/skills/ppt-master/scripts/tests/test_text_measure.py b/skills/ppt-master/scripts/tests/test_text_measure.py
index fe332ff0..08f8e90c 100644
--- a/skills/ppt-master/scripts/tests/test_text_measure.py
+++ b/skills/ppt-master/scripts/tests/test_text_measure.py
@@ -49,6 +49,31 @@ def _run_cli(*args: str) -> subprocess.CompletedProcess[str]:
)
+class CalibrateRoleWeightTests(unittest.TestCase):
+ def test_role_argument_accepts_a_bold_suffix(self) -> None:
+ from text_measure import _role_argument
+
+ self.assertEqual(_role_argument('title:Arial:36'), ('title', 'Arial', 36.0, 'normal'))
+ self.assertEqual(_role_argument('title:Arial:36:bold'), ('title', 'Arial', 36.0, 'bold'))
+
+ def test_bold_role_calibrates_wider(self) -> None:
+ import tempfile
+ from pathlib import Path
+ from text_measure import _calibration_payload
+
+ with tempfile.TemporaryDirectory() as tmp:
+ normal = _calibration_payload(
+ [('title', 'Arial', 36.0)], project_path=Path(tmp),
+ source='--role', include_outline=False,
+ )['roles']['title']
+ bold = _calibration_payload(
+ [('title', 'Arial', 36.0)], project_path=Path(tmp),
+ source='--role', include_outline=False, weights={'title': 'bold'},
+ )['roles']['title']
+ self.assertEqual(bold['weight'], 'bold')
+ self.assertLess(bold['latin_chars_per_100px'], normal['latin_chars_per_100px'])
+
+
class WrapUnitTests(unittest.TestCase):
def test_percent_sign_stays_with_its_number(self) -> None:
from text_measure import wrap_text
diff --git a/skills/ppt-master/scripts/text_measure.py b/skills/ppt-master/scripts/text_measure.py
index e830e4e6..9f204ede 100644
--- a/skills/ppt-master/scripts/text_measure.py
+++ b/skills/ppt-master/scripts/text_measure.py
@@ -281,12 +281,16 @@ def text_box(
return dict(x=left, y=top, width=width, height=bottom - top, top=top, bottom=bottom)
-def _role_argument(value: str) -> tuple[str, str, float]:
+def _role_argument(value: str) -> tuple[str, str, float, str]:
+ weight = 'normal'
+ parts = value.rsplit(':', 1)
+ if len(parts) == 2 and parts[1].strip().casefold() in _ROLE_WEIGHTS:
+ value, weight = parts[0], parts[1].strip().casefold()
try:
name_and_family, raw_size = value.rsplit(':', 1)
name, family = name_and_family.split(':', 1)
except ValueError as exc:
- raise argparse.ArgumentTypeError('expected NAME:FAMILY:SIZE') from exc
+ raise argparse.ArgumentTypeError('expected NAME:FAMILY:SIZE[:bold]') from exc
name, family = name.strip().casefold(), family.strip()
if not name or not family:
raise argparse.ArgumentTypeError('expected non-empty NAME and FAMILY')
@@ -294,7 +298,10 @@ def _role_argument(value: str) -> tuple[str, str, float]:
size = _positive_float(raw_size)
except (argparse.ArgumentTypeError, ValueError) as exc:
raise argparse.ArgumentTypeError('SIZE must be a positive finite number') from exc
- return name, family, size
+ return name, family, size, weight
+
+
+_ROLE_WEIGHTS = frozenset({'normal', 'bold'})
def _ordered_roles(roles: dict[str, tuple[str, float]]) -> list[tuple[str, str, float]]:
@@ -306,6 +313,7 @@ def _ordered_roles(roles: dict[str, tuple[str, float]]) -> list[tuple[str, str,
def _roles_from_spec_lock(
lock_path: Path,
fallbacks: dict[str, str] | None = None,
+ weights: dict[str, str] | None = None,
) -> dict[str, tuple[str, float]]:
lock = parse_spec_lock(lock_path, report_duplicate_fields=True)
typography = next(
@@ -456,7 +464,9 @@ def _truncate_planned_line(text: str, limit: int = 40) -> str:
def _longest_planned_lines(
project_path: Path,
roles: list[tuple[str, str, float]],
+ weights: dict[str, str] | None = None,
) -> dict[str, dict[str, object] | None]:
+ weights = weights or {}
candidates = _outline_candidates(
project_path / 'design_spec.md',
{name for name, _family, _size in roles},
@@ -465,7 +475,10 @@ def _longest_planned_lines(
for name, family, size in roles:
best: tuple[float, str, str] | None = None
for slide, planned_line in candidates[name]:
- width = measure_text(planned_line, size=size, family=family)
+ width = measure_text(
+ planned_line, size=size, family=family,
+ weight=weights.get(name, 'normal'),
+ )
if best is None or width > best[0]:
best = (width, slide, planned_line)
longest[name] = None if best is None else {
@@ -482,9 +495,11 @@ def _calibration_payload(
project_path: Path,
source: str,
include_outline: bool,
+ weights: dict[str, str] | None = None,
) -> dict[str, object]:
+ weights = weights or {}
longest = (
- _longest_planned_lines(project_path, roles)
+ _longest_planned_lines(project_path, roles, weights)
if include_outline
else {name: None for name, _family, _size in roles}
)
@@ -493,13 +508,16 @@ def _calibration_payload(
digits_length = len(split_project_text_clusters(_CALIBRATION_DIGITS_SAMPLE))
role_rows = {}
for name, family, size in roles:
- cjk_width = measure_text(_CALIBRATION_CJK_SAMPLE, size=size, family=family)
- latin_width = measure_text(_CALIBRATION_LATIN_SAMPLE, size=size, family=family)
- caps_width = measure_text(_CALIBRATION_CAPS_SAMPLE, size=size, family=family)
- digits_width = measure_text(_CALIBRATION_DIGITS_SAMPLE, size=size, family=family)
+ weight = weights.get(name, 'normal')
+ style = dict(size=size, family=family, weight=weight)
+ cjk_width = measure_text(_CALIBRATION_CJK_SAMPLE, **style)
+ latin_width = measure_text(_CALIBRATION_LATIN_SAMPLE, **style)
+ caps_width = measure_text(_CALIBRATION_CAPS_SAMPLE, **style)
+ digits_width = measure_text(_CALIBRATION_DIGITS_SAMPLE, **style)
role_rows[name] = {
'family': family,
'size': size,
+ 'weight': weight,
'cjk_chars_per_100px': round(100.0 * cjk_length / cjk_width, 1),
'latin_chars_per_100px': round(100.0 * latin_length / latin_width, 1),
'caps_chars_per_100px': round(100.0 * latin_length / caps_width, 1),
@@ -605,19 +623,21 @@ def _run_calibrate(args: argparse.Namespace) -> int:
lock_path = project_path / 'spec_lock.md'
if not lock_path.is_file() and not args.role:
print(
- 'Calibration requires spec_lock.md or at least one --role NAME:FAMILY:SIZE entry.',
+ 'Calibration requires spec_lock.md or at least one --role NAME:FAMILY:SIZE[:bold] entry.',
file=sys.stderr,
)
return 2
try:
fallbacks: dict[str, str] = {}
+ weights: dict[str, str] = {}
roles = (
- _roles_from_spec_lock(lock_path, fallbacks)
+ _roles_from_spec_lock(lock_path, fallbacks, weights)
if lock_path.is_file()
else {}
)
- for name, family, size in args.role:
+ for name, family, size, weight in args.role:
roles[name] = (family, size)
+ weights[name] = weight
fallbacks.pop(name, None)
ordered_roles = _ordered_roles(roles)
if not ordered_roles:
@@ -628,8 +648,17 @@ def _run_calibrate(args: argparse.Namespace) -> int:
project_path=project_path,
source=source,
include_outline=args.outline,
+ weights=weights,
)
payload['notes'] = _fallback_notes(roles, fallbacks)
+ bold_roles = sorted(name for name, weight in weights.items() if weight == 'bold')
+ payload['notes'].append(
+ 'rates for ' + ', '.join(bold_roles) + ' are measured at bold weight'
+ if bold_roles else
+ 'every role is measured at normal weight; recalibrate a role '
+ 'realized as bold deck-wide with --role NAME:FAMILY:SIZE:bold, '
+ 'since bold runs about 7% wider'
+ )
output_path = project_path / 'validation' / 'text_calibration.json'
output_path.parent.mkdir(parents=True, exist_ok=True)
if args.role and output_path.is_file():
@@ -705,7 +734,7 @@ def build_parser() -> argparse.ArgumentParser:
action='append',
type=_role_argument,
default=[],
- metavar='NAME:FAMILY:SIZE',
+ metavar='NAME:FAMILY:SIZE[:bold]',
help='Typography role to calibrate when spec_lock.md is absent, e.g. '
'body:"Microsoft YaHei":20; repeatable.',
)