pptx/text-color

A text box carries a run whose font color is set to solid red (#FF0000) via <a:solidFill>/<a:srgbClr>.

Library verdicts: python-pptx: — pptxjs: fail

Metadata

Feature idpptx/text-color
Formatpptx
Categorytext-formatting
Spececma-376-5-part-1 § 21.1.2.3.8 a:solidFill

XPath assertions

ID / partPredicateXPathpython-pptxpptxjs
text-color-solid-fill-rgb
ppt/slides/slide1.xml
equal = FF0000
The run carrying the 'Red colored slide text' string must declare <a:solidFill>/<a:srgbClr val="FF0000"/> in its <a:rPr>.
//a:r[a:t[normalize-space()='Red colored slide text']]/a:rPr/a:solidFill/a:srgbClr/@val
text-color-text-present
ppt/slides/slide1.xml
exist
The slide must contain a text run with value 'Red colored slide text'.
//a:t[normalize-space()='Red colored slide text']

Render assertions

IDPredicateSelectorpython-pptxpptxjs
text-color-computed-redcomputed_style/ match-text = ^(rgb\(255,\s*0,\s*0\)|#ff0000|#FF0000|red)$ style=color
The computed color of the DOM node carrying the red text must resolve to red (rgb(255, 0, 0), #ff0000, or the named color 'red').
[data-shape-type='textbox'], .pptx-textbox, section[data-slide] p, section.slide pfail
slide-countcss_selector/ equal-count
Exactly one slide container must be rendered. Catches renderers that emit zero slides (hard failure) or duplicate the slide.
section.pptx-slide, .pptx-slide, section[data-slide], .slide, [data-slide]

Generator source

scripts/gen_text_color.py

#!/usr/bin/env python3
"""Generate ``fixtures/pptx/text-color.pptx``.

A one-slide presentation whose text box carries a run with solid red
font color (#FF0000), emitted as <a:solidFill>/<a:srgbClr val="FF0000"/>.
Designed to satisfy the assertions in ``features/pptx/text-color.json``.
"""

from __future__ import annotations

from pathlib import Path

from pptx import Presentation
from pptx.dml.color import RGBColor
from pptx.util import Inches

import datetime as _dt
_REPRODUCIBLE_DT = _dt.datetime(2000, 1, 1, 0, 0, 0)

_REPO_ROOT = Path(__file__).resolve().parent.parent
_OUT = _REPO_ROOT / "fixtures" / "pptx" / "text-color.pptx"


def main() -> int:
    prs = Presentation()
    slide = prs.slides.add_slide(prs.slide_layouts[5])
    tb = slide.shapes.add_textbox(Inches(1), Inches(1), Inches(4), Inches(1))
    tf = tb.text_frame
    tf.text = "Red colored slide text"
    run = tf.paragraphs[0].runs[0]
    run.font.color.rgb = RGBColor(0xFF, 0x00, 0x00)
    _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())

Manifest (expanded)

{
  "$schema": "../manifest.schema.json",
  "id": "pptx/text-color",
  "title": "Run-level text color (solid fill)",
  "format": "pptx",
  "category": "text-formatting",
  "summary": "A text box carries a run whose font color is set to solid red (#FF0000) via <a:solidFill>/<a:srgbClr>.",
  "spec": {
    "source": "ecma-376-5-part-1",
    "clause": "21.1.2.3.8",
    "element": "a:solidFill",
    "rnc_reference": "spec/ecma-376-5/part-1/rnc/DrawingML.rnc",
    "xsd_reference": "spec/ecma-376-5/part-1/xsd/dml-text.xsd",
    "notes": "python-pptx emits run.font.color.rgb = RGBColor(...) as <a:rPr>/<a:solidFill>/<a:srgbClr val=\"FF0000\"/> inside the run's <a:r>. The value is a six-hex-digit RGB triplet, uppercase."
  },
  "fixtures": {
    "machine": "pptx/text-color",
    "office": "pptx/text-color"
  },
  "generator": {
    "python": "scripts/gen_text_color.py"
  },
  "assertions": [
    {
      "id": "text-color-solid-fill-rgb",
      "part": "ppt/slides/slide1.xml",
      "namespaces": {
        "p": "http://schemas.openxmlformats.org/presentationml/2006/main",
        "a": "http://schemas.openxmlformats.org/drawingml/2006/main"
      },
      "xpath": "//a:r[a:t[normalize-space()='Red colored slide text']]/a:rPr/a:solidFill/a:srgbClr/@val",
      "must": "equal",
      "value": "FF0000",
      "description": "The run carrying the 'Red colored slide text' string must declare <a:solidFill>/<a:srgbClr val=\"FF0000\"/> in its <a:rPr>."
    },
    {
      "id": "text-color-text-present",
      "part": "ppt/slides/slide1.xml",
      "namespaces": {
        "p": "http://schemas.openxmlformats.org/presentationml/2006/main",
        "a": "http://schemas.openxmlformats.org/drawingml/2006/main"
      },
      "xpath": "//a:t[normalize-space()='Red colored slide text']",
      "must": "exist",
      "description": "The slide must contain a text run with value 'Red colored slide text'."
    }
  ],
  "render_assertions": [
    {
      "id": "text-color-computed-red",
      "kind": "computed_style",
      "selector": "[data-shape-type='textbox'], .pptx-textbox, section[data-slide] p, section.slide p",
      "style_property": "color",
      "must": "match-text",
      "value": "^(rgb\\(255,\\s*0,\\s*0\\)|#ff0000|#FF0000|red)$",
      "description": "The computed color of the DOM node carrying the red text must resolve to red (rgb(255, 0, 0), #ff0000, or the named color 'red')."
    },
    {
      "id": "slide-count",
      "kind": "css_selector",
      "selector": "section.pptx-slide, .pptx-slide, section[data-slide], .slide, [data-slide]",
      "must": "equal-count",
      "count": 1,
      "description": "Exactly one slide container must be rendered. Catches renderers that emit zero slides (hard failure) or duplicate the slide."
    }
  ]
}

Fixture

Download text-color.pptx (27.6 KB)

Reference preview

Reference (machine, page 1 PNG)

pptx/text-color page 1 reference

Reference PDF


Download PDF Open in PDF.js

Spec notes

python-pptx emits run.font.color.rgb = RGBColor(...) as <a:rPr>/<a:solidFill>/<a:srgbClr val="FF0000"/> inside the run's <a:r>. The value is a six-hex-digit RGB triplet, uppercase.