OfficeOpenXML.com
 

DrawingML Shapes

Text - Body Properties - Fit, Wrap, Warp and 3D

Text Fit:

Text within a shape can be specified so that it is automatically scaled to fit within the text box. Alternatively the shape can be scaled to fit the text. Scaling of text can also be turned off so that text outside of the text box is not displayed. In fact, that is the default behavior--no scaling. Finally, there are two attributes that affect the fit of text horizonally and vertially. (Note also that text wrapping can affect whether text remains within the box. See text wrapping, below.) First we discuss the overall scaling that is specified with child elements of <a:bodyPr>.

To scale the text, add <a:normAutoFit> as a child of <a:bodyPr>. There are two attributes which affect the scaling. First, you can specify the percentage of the original font size to which the text is scaled with the fontScale attribute, specified as a percent. (If omitted, the value is assumed to be 100%.) Second, specify the percent by which the line spacing of paragraphs is reduced with the lnSpcReduction attribute, also a percent. (If omitted, the value is assumed to be 0%.)

<xdr:txBody>
<a:bodyPr vertOverflow="clip" rtlCol="0" anchor="ctr">
<a:normAutoFit fontScale="75%" lnSpcReduction="20%"/>
</a:bodyPr>
<a:lstStyle/>
<a:p>
<a:pPr algn="l"/>
<a:r>
<a:rPr lang="en-US" sz="1100"/>
<a:t>This is a paragraph of text within the shape.</a:t>
</a:r>
</a:p>
<a:p>
<a:pPr algn="ctr"/>
<a:r>
<a:rPr lang="en-US" sz="1100"/>
<a:t>This is the second paragraph.</a:t>
</a:r>
</a:p>
</xdr:txBody>

Below is an example of a shape with text. The text fits within the box.

Shape with text

Below is the same shape, but with an additional paragraph of text. When we specify <a:normAutoFit fontScale="75%" lnSpcReduction="20%"/>, the text is scaled to fit within the shape, as shown below.

Shape with text - text scaling

If we turn off scaling by replacing <a:normAutoFit> with <a:noAutoFit />, the text no longer fits within the box, as shown by the two images below.

Shape with text Shape with text

If instead we want the shape itself to scale to the text, then we add <a:spAutoFit />. Below is the shape with the additional third paragraph, but also an additional fourth and fifth paragraphs typed into it. Note that with Word, the resizing does not occur until additional text is added to the shape.

Shape with text - text scaling

In addition to the above elements which affect overall scaling, there are also two attributes of <a:bodyPr> which affect the fit of text within a shape. They are horzOverflow and vertOverflow. They determiine whether text can flow out of the bounding box horizonally and vertically. Possibly values for horzOverflow are:

Possibly values for vertOverflow are:

Below is a sample shape with excess text, first with the default behaviors. The second example shows the shape with vertical overflow set to clip (<a:bodyPr rtlCol="0" anchor="ctr" vertOverflow="clip"/>). The third example shows the shape with vertical overflow set to ellipsis (<a:bodyPr rtlCol="0" anchor="ctr" vertOverflow="ellipsis"/>).

Shape with text - text overflow

Shape with text - text overflow Shape with text - text overflow

Text Wrap:

Text wrapping may be turned on or off with the wrap attribute on <a:bodyPr>. Possible values are square and none. By default text is wrapped inside the bounding box (<a:bodyPr . . . wrap="square" />). Below is a shape with wrapping turned off (<a:bodyPr . . . wrap="none" />).

Shape with text - text wrap

Text Warp:

A piece of text within a shape can be warped by specifying a preset shape to be applied to the text, thereby warping the text. This is done by including the <a:prstTxWarp> element as a child of <a:bodyPr>. The actual shape to apply as the warping effect is given in the prst attribute of <a:prstTxWarp>. Possible values are given below. Note that a list of shape adjustment values (<a:avLst>) can be specified as a child element of <a:prstTxWarp>. These adjustment values are not covered here.

Below is some text with a downward arch (textArchDown) applied to the text.

<xdr:txBody>
<a:bodyPr vertOverflow="clip" rtlCol="0" anchor="ctr">
<a:prstTxWarp prst="textArchDown"/>
<a:avLst/>
</a:prstTxWarp>
</a:bodyPr>
<. . .;
</xdr:txBody>

Shape with text

Line Spacing:

There are a couple of attributes on <a:bodyPr> that affect the spacing of lines of text within a shape. First, spcFirstLastPara determines whether the spacing between paragraphs as specified by the user is respected for the first and last paragraphs within the shape. If the attribute value is set to false (the default), then the paragraph spacing is not respected for the first and last paragraphs. Below is a shape with paragraphs of text with a specified spacing before of 12 points. The first sample respects the paragraph spacing (<a:bodyPr anchor="ctr" rtlCol="0" spcFirstLastPara="1"/>) and the second does not (<a:bodyPr anchor="ctr" rtlCol="0" spcFirstLastPara="0"/>).

Shape with text - line spacing Shape with text - line spacing

There is also a compatLnSpc attribute which specifies whether line spacing is determined in a simplistic mmaer using the font scene. Values are either trust or false (the default).

Anti-Aliased Text:

Text within a shape can be forced to be rendered anti-aliased regardless of the font size by specifying the forceAA attribute on <a:bodyPr>. A value of true will force anti-aliasing; the default is false.

3D Properties:

As with shapes, it is possible to specify 3D properties for text within shapes. They are specified for text within shapes just as they are with the shapes, except that the containing element is the <a:bodyPr> element rather than the <a:spPr> element. See 3D Shape Properties for details on extrusion, contours, and bevels. See 3D Scene Properties for details on camera and light rig. Note that there is also a <a:flatTx> element to indicate that there should be no text in a 3D scene. It is an empty child element of span class="featuredItem"><a:bodyPr>.

Below is a sample shape with text that has 3D properties.

<xdr:txBody>
<a:bodyPr rtlCol="0" anchor="ctr">
<a:scene3d>
<a:camera prst="isometricRightUp"/>
<a:lightRig rig="freezing" dir="t">
<a:rot lat="0" lon="0" rev="15600000"/>
</a:lightRig>
</a:scene3d>
<a:sp3d extrusionH="57150" contourW="31750" prstMaterial="softEdge">
<a:bevelT w="38100" h="38100" prst="relaxedInset"/>
<a:bevelB w="38100" h="38100" prst="coolSlant"/>
<a:extrusionClr>
<a:schemeClr val="accent2">
<a:lumMod val="6000">
<a:lumOff val="4000">
</a:schemeClr>
</a:extrusionClr>
<a:contourClr>
<a:schemeClr val="tx2">
<a:lumMod val="6000">
<a:lumOff val="4000">
</a:schemeClr>
</a:contourClr>
</a:sp3d>
</a:bodyPr>
<. . .;
</xdr:txBody>

Shape with text in 3D