theme
theme
¶
The Theme object, the document's theme fonts and colours.
_ThemeFont
¶
_ThemeFont(fontCollection: object)
One font collection of a theme — its major or minor fonts.
Source code in src/docx/theme.py
latin
property
¶
The Latin typeface of this collection, e.g. "Calibri".
This is what a minorHAnsi or majorHAnsi theme token resolves to, and the one
that matters for a Western document.
east_asian
property
¶
The East Asian typeface of this collection, or None when it sets none.
The default Office theme leaves this empty and relies on the a:font script
entries instead, so None here is ordinary rather than exceptional.
complex_script
property
¶
The complex-script typeface of this collection, or None when it sets none.
Theme
¶
Theme(
theme: CT_OfficeStyleSheet, part: XmlPart | None = None
)
Bases: ElementProxy
The document's theme: its major and minor fonts and its twelve theme colours.
Reached through Document.theme, which is None for a document carrying no
theme part.
The point of exposing it is Font.theme_typeface: a run whose font is set
only by a theme token reports None for Font.name, and this is where the
concrete typeface behind that token lives.
Source code in src/docx/theme.py
major_font
property
¶
major_font: _ThemeFont
The theme's major fonts, which Word applies to headings.
minor_font
property
¶
minor_font: _ThemeFont
The theme's minor fonts, which Word applies to body text.
colors
property
¶
colors: dict[str, RGBColor | str | None]
The twelve theme colours, keyed by slot name, in schema order.
typeface
¶
The concrete typeface theme_token names, or None when there is none.
theme_token is a w:rFonts/@w:asciiTheme-style value such as "minorHAnsi".
An unrecognised token, and a token whose slot the theme leaves empty, both give
None.
Source code in src/docx/theme.py
color
¶
color(name: str) -> RGBColor | str | None
The RGB value of theme colour name, or None when the theme has none.
name is one of dk1, lt1, dk2, lt2, accent1 through
accent6, hlink and folHlink — the slot names as they appear in the
XML. A MSO_THEME_COLOR member's own spelling differs; this takes the XML one
because that is what the theme part is keyed on.
A system colour such as dk1 reports the RGB value the producing application
last resolved it to, which is the only concrete value available outside that
operating system.