The PresentationML placeholder-text inheritance chain: a title placeholder populated via python-pptx's ``slide.shapes.title.text = ...`` must rely on the theme-typeface cascade (slide -> layout -> master). The emitted slide carries a run with no <a:rPr> — no run-level override — so the font must come from the slide layout, which itself delegates via empty <a:lstStyle/> to the slide master's <p:titleStyle>/<a:lvl1pPr>/<a:defRPr>/<a:latin typeface='+mj-lt'/>. The three-part cascade is asserted directly: run has no rPr; layout title carries no latin typeface override on its defRPr (none declared at all); master titleStyle declares <a:latin typeface='+mj-lt'/>.
Library verdicts: python-pptx: — pptxjs: —
| Feature id | pptx/placeholder-inheritance |
|---|---|
| Format | pptx |
| Category | slide-content |
| Spec | ecma-376-5-part-1 § 19.3.1.42 p:ph |
| ID / part | Predicate | XPath | python-pptx | pptxjs |
|---|---|---|---|---|
slide-title-run-has-no-rPrppt/slides/slide1.xml | absentThe slide's title-placeholder run must carry NO <a:rPr>. Inheritance only applies when run-level properties are absent; if <a:rPr> is present, the slide overrides the cascade for that property. | //p:sp[p:nvSpPr/p:nvPr/p:ph[@type='title' or @type='ctrTitle']]/p:txBody/a:p/a:r/a:rPr | — | — |
layout-title-defines-no-latin-overrideppt/slideLayouts/slideLayout6.xml | absentThe 'Title Only' layout's title-placeholder must not define its own <a:latin typeface=.../> override at level-1 default-rPr, so the typeface falls through to the master. | //p:sp[p:nvSpPr/p:nvPr/p:ph[@type='title']]/p:txBody/a:lstStyle/a:lvl1pPr/a:defRPr/a:latin | — | — |
master-titleStyle-declares-major-latinppt/slideMasters/slideMaster1.xml | equal = +mj-ltThe slide master's <p:titleStyle>/<a:lvl1pPr>/<a:defRPr>/<a:latin> must declare typeface='+mj-lt' — the theme-scheme reference to the major-latin font. Combined with the absent run-rPr and absent layout-level-1 latin override, this structurally demonstrates the slide -> layout -> master typeface cascade. | //p:titleStyle/a:lvl1pPr/a:defRPr/a:latin/@typeface | — | — |
No render assertions declared.
scripts/gen_placeholder_inheritance.py
#!/usr/bin/env python3
"""Generate ``fixtures/pptx/placeholder-inheritance.pptx``.
A minimal presentation exercising the PresentationML placeholder-text
inheritance cascade. The generator uses the "Title Only" layout
(``prs.slide_layouts[5]``) and assigns plain text to the title
placeholder via ``slide.shapes.title.text``. python-pptx's default
``.text`` setter creates a <a:r> with no <a:rPr> — exactly the shape
needed to demonstrate that the typeface comes from the cascade
(slide -> layout -> master), not from a run-level override on the
slide itself.
Designed to satisfy the assertions in
``features/pptx/placeholder-inheritance.json``:
- slide title run carries no <a:rPr>
- layout's title placeholder declares no <a:latin> override at
level-1 default-rPr (empty <a:lstStyle/>)
- master's <p:titleStyle>/<a:lvl1pPr>/<a:defRPr> carries
<a:latin typeface='+mj-lt'/>
Together those three assertions structurally demonstrate the three-
level typeface cascade without collapsing it to a single rendered-
font equality check.
"""
from __future__ import annotations
import datetime as _dt
from pathlib import Path
from pptx import Presentation
_REPRODUCIBLE_DT = _dt.datetime(2000, 1, 1, 0, 0, 0)
_REPO_ROOT = Path(__file__).resolve().parent.parent
_OUT = _REPO_ROOT / "fixtures" / "pptx" / "placeholder-inheritance.pptx"
def main() -> int:
prs = Presentation()
# "Title Only" layout — one title placeholder, nothing else to distract.
# Its layout part is emitted as ppt/slideLayouts/slideLayout6.xml by the
# default template; the slide references it via rId1.
slide = prs.slides.add_slide(prs.slide_layouts[5])
# Setting .text via the placeholder.text setter produces a run with no
# <a:rPr> — no run-level override — exactly the shape required to show
# typeface inheritance up the cascade.
slide.shapes.title.text = "Cascade test"
_OUT.parent.mkdir(parents=True, exist_ok=True)
prs.save(_OUT, zip_date_time=_REPRODUCIBLE_DT)
print(_OUT)
return 0
if __name__ == "__main__":
raise SystemExit(main())
{
"$schema": "../manifest.schema.json",
"id": "pptx/placeholder-inheritance",
"title": "Placeholder inheritance (slide -> layout -> master)",
"format": "pptx",
"category": "slide-content",
"summary": "The PresentationML placeholder-text inheritance chain: a title placeholder populated via python-pptx's ``slide.shapes.title.text = ...`` must rely on the theme-typeface cascade (slide -> layout -> master). The emitted slide carries a run with no <a:rPr> — no run-level override — so the font must come from the slide layout, which itself delegates via empty <a:lstStyle/> to the slide master's <p:titleStyle>/<a:lvl1pPr>/<a:defRPr>/<a:latin typeface='+mj-lt'/>. The three-part cascade is asserted directly: run has no rPr; layout title carries no latin typeface override on its defRPr (none declared at all); master titleStyle declares <a:latin typeface='+mj-lt'/>.",
"spec": {
"source": "ecma-376-5-part-1",
"clause": "19.3.1.42",
"element": "p:ph",
"rnc_reference": "spec/ecma-376-5/part-1/rnc/PresentationML.rnc",
"xsd_reference": "spec/ecma-376-5/part-1/xsd/pml.xsd",
"notes": "A placeholder shape (<p:sp> with <p:nvSpPr>/<p:nvPr>/<p:ph>) on a slide inherits its unset run/paragraph properties from the matching placeholder on its slide layout, which in turn inherits from the slide master. For typeface inheritance specifically: the master's <p:txStyles>/<p:titleStyle>/<a:lvl1pPr>/<a:defRPr> declares <a:latin typeface='+mj-lt'/> — where '+mj-lt' is the theme-scheme reference to the major-latin typeface resolved from <a:theme>/<a:fontScheme>/<a:majorFont>/<a:latin>. The slide layout's title placeholder has an empty <a:lstStyle/> (no level-1 paragraph properties), so it falls through to the master. The slide-level title shape has no <a:lstStyle> children and the run has no <a:rPr>, so it falls through via the layout to the master. This feature is asserted as a three-part cascade check rather than a single font-equality assertion because testing only the rendered font would mask the cascade: a library could mis-implement inheritance and still produce the right rendered font by accident (e.g. by embedding +mj-lt on the slide run). The three assertions together require that the cascade be observable as structurally empty slide + empty layout lstStyle + populated master titleStyle."
},
"fixtures": {
"machine": "pptx/placeholder-inheritance"
},
"generator": {
"python": "scripts/gen_placeholder_inheritance.py"
},
"assertions": [
{
"id": "slide-title-run-has-no-rPr",
"part": "ppt/slides/slide1.xml",
"namespaces": {
"p": "http://schemas.openxmlformats.org/presentationml/2006/main",
"a": "http://schemas.openxmlformats.org/drawingml/2006/main"
},
"xpath": "//p:sp[p:nvSpPr/p:nvPr/p:ph[@type='title' or @type='ctrTitle']]/p:txBody/a:p/a:r/a:rPr",
"must": "absent",
"description": "The slide's title-placeholder run must carry NO <a:rPr>. Inheritance only applies when run-level properties are absent; if <a:rPr> is present, the slide overrides the cascade for that property."
},
{
"id": "layout-title-defines-no-latin-override",
"part": "ppt/slideLayouts/slideLayout6.xml",
"namespaces": {
"p": "http://schemas.openxmlformats.org/presentationml/2006/main",
"a": "http://schemas.openxmlformats.org/drawingml/2006/main"
},
"xpath": "//p:sp[p:nvSpPr/p:nvPr/p:ph[@type='title']]/p:txBody/a:lstStyle/a:lvl1pPr/a:defRPr/a:latin",
"must": "absent",
"description": "The 'Title Only' layout's title-placeholder must not define its own <a:latin typeface=.../> override at level-1 default-rPr, so the typeface falls through to the master."
},
{
"id": "master-titleStyle-declares-major-latin",
"part": "ppt/slideMasters/slideMaster1.xml",
"namespaces": {
"p": "http://schemas.openxmlformats.org/presentationml/2006/main",
"a": "http://schemas.openxmlformats.org/drawingml/2006/main"
},
"xpath": "//p:titleStyle/a:lvl1pPr/a:defRPr/a:latin/@typeface",
"must": "equal",
"value": "+mj-lt",
"description": "The slide master's <p:titleStyle>/<a:lvl1pPr>/<a:defRPr>/<a:latin> must declare typeface='+mj-lt' — the theme-scheme reference to the major-latin font. Combined with the absent run-rPr and absent layout-level-1 latin override, this structurally demonstrates the slide -> layout -> master typeface cascade."
}
]
}
