Text in a slide, notes page or table cell is DrawingML, in the namespace
http://schemas.openxmlformats.org/drawingml/2006/main, shortened to
a:. A shape’s p:txBody holds paragraphs, and a paragraph holds
runs.
<p:txBody>
<a:bodyPr/>
<a:lstStyle/>
<a:p>
<a:pPr lvl="1"><a:buChar char="•"/></a:pPr>
<a:r>
<a:rPr lang="en-GB" b="1"/>
<a:t>A bold point</a:t>
</a:r>
</a:p>
</p:txBody>
Paragraphs and runs
| Element | Holds |
|---|---|
a:bodyPr | Text box properties: rotation, wrapping and insets. |
a:lstStyle | Local list style overrides. |
a:p | A paragraph. |
a:pPr | Paragraph properties: lvl (0 to 8), algn, spacing, indent. |
a:r | A run of text with the same formatting. |
a:rPr | Run properties: b, i, u, strike, sz in hundredths of a point, colour and font. |
a:t | The text. |
a:br | A line break within the paragraph. |
a:fld | A field, such as the slide number, with its current text in a:t. |
a:endParaRPr | Formatting for the end of the paragraph. |
Rules, attributes and defaults
Sources read: ECMA-376 5th edition Part 1 (research/ooxml/ecma376/p1/part1.txt) 21.1.2.1.1 (bodyPr),
21.1.2.2.7 (pPr), 21.1.2.3.9 (rPr) and the Annex A.4.1 types CT_TextBodyProperties,
CT_TextParagraphProperties, CT_TextCharacterProperties and ST_TextFontSize.
a:bodyPr
- Children in order:
prstTxWarp, one ofnoAutofit,normAutofitorspAutoFit,scene3d, one ofsp3dorflatTx,extLst. No autofit element means no autofit. - Defaults when an attribute is omitted:
anchortop;anchorCtrfalse;lInsandrIns91440 EMU (0.1 in);tInsandbIns45720 EMU (0.05 in);numCol1;spcCol0;rtlColfalse (columns fill from the left; it does not set the text direction);rot0 (when absent the shape’s rotation applies; when present it is applied on its own, in addition to the shape’s);verthorz;wrapsquare;horzOverflowandvertOverflowoverflow;spcFirstLastPara,upright,fromWordArt,forceAAandcompatLnSpcfalse. spcFirstLastParaonly affects the space before the first paragraph and the space after the last one.uprightkeeps the text unrotated whatever the shape’s transform. Columns overflow from one into the next, and the overflow attributes apply once all are full.
a:pPr
- Children in order:
lnSpc,spcBef,spcAft, a bullet colour, a bullet size, a bullet typeface, a bullet (buNone,buAutoNum,buCharorbuBlip),tabLst,defRPr,extLst. - Defaults when omitted:
algnleft;marL347663;marR0;indent-342900 (0 puts the first line atmarL);lvl0, with the range 0 to 8 selectinglvl1pPrtolvl9pPr;rtlfalse;eaLnBrkandlatinLnBrktrue;fontAlgnbase;hangingPunctfalse.defTabSzsets the width of a tab inside the text, whilemarLandindenthandle indentation. marLandmarRare added to the body insets. The standard’s rule (21.1.2.2.7) is that a property defined nearer the text wins, sopPrbeats the matchinglvlNpPrin a list style.
a:rPr
- Children in order:
ln, a fill, an effect,highlight, an underline line, an underline fill,latin,ea,cs,sym,hlinkClick,hlinkMouseOver,rtl,extLst. szis in hundredths of a point and limited to 100 through 400000 (1 to 4000 pt). When omitted the value fromdefRPror the inherited style is used.kernis the smallest size, in the same units, at which kerning applies; omitted means kerning at all sizes.spcis the extra space between characters (0 when omitted).baselineis a percentage of the font size for superscript (positive) and subscript (negative).b,i,kumimojiandnormalizeHdefault to false;uandstrikedefault to none;capandnormalizeHchange only how the text is drawn, never the stored characters.dirtydefaults to true anderrto false (the spell check state);smtCleandefaults to true andsmtIdto 0 (smart tags).langandaltLangare language codes; withoutaltLangthelangvalue is used.a:rtlinsiderPrmakes the run complex script (thecsfont is used) and overrides the character direction. It is separate from the paragraph’srtlattribute.
Divergence from spec: what libraries do
Sources read: python-pptx oxml/text.py (research/pptx/src/pptx-oxml-text.py) and Apache POI
XSLFTextShape.java, XSLFTextRun.java and XSLFTextParagraph.java
(research/pptx/src/poi-*.java, fetched from the POI trunk).
- Insets. The standard’s defaults (91440 and 45720 EMU) are what python-pptx declares for
lIns,rIns(91440) andtIns,bIns(45720) inCT_TextBodyProperties(lines 217-228), and what POI returns when the attribute is missing anywhere up the inheritance chain (7.2 pt and 3.6 pt,XSLFTextShape.getLeftInsetandgetBottomInset, which cite “0.1 inches” and “0.05 inches”). No divergence. - Autofit. python-pptx reports the three autofit children as an enumeration (none, text to fit shape, shape to fit
text) and nothing when no child is present (lines 236-245);
fontScaledefaults to 100 percent (CT_TextNormalAutofit, line 392). The standard (21.1.2.1.3,normAutofit) saysfontScaleis the percentage of the original size (default 100%), and thatlnSpcReduction(default 0%) is “applied by subtracting it from the original line spacing value” and only to paragraphs with percentage line spacing. POI multiplies the run size byfontScaleinXSLFTextRun.getFontSize(lines 266-285), and multiplies a positive (percentage) line spacing by1 - lnSpcReductioninXSLFTextParagraph.getLineSpacing(lines 531-543): the font scale agrees with the standard, the line spacing is a product where the standard says a subtraction. - Paragraph spacing. The standard lets
spcBef,spcAftandlnSpchold eitherspcPtsorspcPct. python-pptx’sspace_beforeandspace_afterread onlyspcPtsand return nothing for a percentage (lines 538-569), whileline_spacingreturns a number of lines forspcPctand a length forspcPts(lines 513-525). - Text of a run. python-pptx escapes control characters 0x00-0x08 and 0x0B-0x1F written into
a:tas_xHHHH_(lines 68-76), keeping tab and line feed; it returns a vertical-tab character for eacha:br(line 385) and the text ofa:fldfrom itsa:tchild. It declaresa:rPrbeforea:tanda:endParaRPrlast, as the schema orders them. - Level.
lvldefaults to 0 in python-pptx (line 505) as in the standard. - Child orders, checked against
dml-main.xsd(Transitional, lines 2562, 2681, 2997, 3059, 3075). Agreement:a:risrPr?, t(python-pptx lines 52-55);a:brisrPr?(line 376);a:fldisrPr?, pPr?, t?(lines 344-349:rPrlistspPrandtas successors);a:pispPr?, any mix ofr,br,fld,endParaRPr?(lines 405-412);a:pPrchild sequence (lines 473-491) equals the schema order;a:txBodyrequiresbodyPrand at least onep(lines 88-91). Not modelled by python-pptx:a:lstStyleinCT_TextBody(optional in the schema, written by itsp:txBodytemplate at line 195 but not by thea:txBodytemplate at line 182); the requiredid(GUID) and optionaltypeattributes ofa:fld(lines 339-357 declare neither); text-run properties other thanlang,sz,b,i,u(lines 317-327);a:bodyPrattributes other than the four insets,anchorandwrap(lines 217-234);algnandlvlare the onlya:pPrattributes (lines 504-509). Reading such a file is unaffected: lxml keeps every unmodelled attribute and child. The explorer (render.jslines 586-612) draws ana:fldas its storeda:ttext with thea:rPrformatting, does not recompute the field from itstypeand ignores the field’s owna:pPr; a field with noa:tdraws nothing. - Default autofit (POI).
XSLFTextShape.getTextAutofit(lines 637-649) returns normal whenbodyPrhas none ofnoAutofit,normAutofit,spAutoFit; the standard (21.1.2.1.1) and python-pptx (line 245, returns nothing) treat a missing element as no autofit. The explorer follows the standard. - Text direction (POI).
getTextDirection(lines 354-370) reads only the shape’s ownbodyPr(no inheritance from the layout or master, unlike insets,anchor,anchorCtr,wrap) and foldsvert,eaVertandmongolianVertinto one “vertical” value,vert270into “vertical 270”,wordArtVertandwordArtVertRtlinto “stacked”; the seven values ofST_TextVerticalType(20.1.10.83) stay distinct in the file. The explorer inheritsvertfrom the placeholder chain like the other attributes, and draws every value excepthorzandvert270as a 90 degree turn andvert270as minus 90 (render.js1004-1006); stacked and Mongolian letter orientation is not drawn. - Vertical anchor, centring, wrap (POI). Missing
anchorgives top, missinganchorCtrfalse and missingwraptrue (square) after walking the inheritance chain (lines 292-337, 573-587): the same defaults as the standard.rotis returned in degrees (rot/ 60000, lines 372-379) from the shape’s ownbodyPronly. - Setting text (POI).
appendText(lines 155-220) starts a paragraph at each CR, LF or CR LF and a line break at each vertical-tab character, copying the properties of the last run; python-pptx’sappend_text(lines 425-439) breaks at LF and vertical tab alike inside one paragraph. A writer difference only: both write schema-valida:p,a:r,a:br. - Viewer state of body properties. Drawn: the four insets,
anchor(justspaces the lines out evenly over the area inside the insets, a single line sits at the top;distdoes the same, a single line sits in the middle, as 20.1.10.60 says; for vertical text the letters are not distributed),numCol(1 to 16) withspcCol(the text is filled into one column after the other, each column as high as the area inside the insets;rtlColreverses the order of the columns),upright(the text is drawn unturned inside a rotated shape, about the centre of the text box),spAutoFit(the shape grows to the height of its text: downward for top anchoring, upward for bottom, both ways for centre, because the spec gives no direction; not for rotated shapes, columns or vertical text; it never shrinks),anchorCtr(the smallest bounds box of the lines, as 21.1.2.1.1 describes, centred in the area inside the insets),wrap,rot(about the centre of the text box, on top of the shape’s rotation),vert,normAutofitfontScaleandlnSpcReduction. Not drawn:spcFirstLastPara,horzOverflowandvertOverflow(text always overflows),flatTx.prstTxWarp(20.1.9.19) is drawn: each paragraph becomes one line, in the first run’s size, colour and weight, set glyph by glyph along the paths of the standard’spresetTextWarpDefinitions.xml(shared/textwarp.js, the same code as in DOCX); the fitting of glyphs to the paths is an approximation because the standard gives the paths but no rule for the fitting, runs of different sizes within a paragraph are not told apart, andtextNoShapeleaves the text straight. - Tab stops. POI reads
a:tabLsttab by tab and takesdefTabSzas a separate length (XSLFTextParagraphlines 493-522, 955-966); it does not combine the two. No rule of the standard is contradicted.
Bullets and levels
A paragraph’s lvl attribute picks a level in the master’s text styles, which
usually set a bullet for each level of body text. a:buNone removes the
bullet, a:buChar sets a character, a:buAutoNum numbers the
paragraphs and a:buBlip uses a picture.
Hyperlinks
A run’s a:hlinkClick has an r:id pointing to a
hyperlink relationship, with the target there. Actions such as
“next slide” use the action attribute instead.
The explorer shows a link only when its target is a web or mail address, and shows other targets as plain text.