Font typeface

Overview

PowerPoint allows the font of text elements to be changed from, for example, Verdana to Arial. This aspect of a font is its typeface, as opposed to its size (e.g. 18 points) or style (e.g. bold, italic).

Minimum viable feature

>>> assert isinstance(font, pptx.text.Font)
>>> font.name
None
>>> font.name = 'Verdana'
>>> font.name
'Verdana'

Protocol

>>> assert isinstance(font, pptx.text.Font)
>>> font.name
None
>>> font.name = 'Verdana'
>>> font.name
'Verdana'

XML specimens

Here is a representative sample of textbox XML showing the effect of applying a non-default typeface.

Baseline default textbox:

<p:txBody>
  <a:bodyPr wrap="none" rtlCol="0">
    <a:spAutoFit/>
  </a:bodyPr>
  <a:lstStyle/>
  <a:p>
    <a:r>
      <a:rPr lang="en-US" dirty="0" smtClean="0"/>
      <a:t>Baseline default textbox, no adjustments of any kind</a:t>
    </a:r>
    <a:endParaRPr lang="en-US" dirty="0"/>
  </a:p>
</p:txBody>

textbox with typeface applied at shape level:

<p:txBody>
  <a:bodyPr wrap="none" rtlCol="0">
    <a:spAutoFit/>
  </a:bodyPr>
  <a:lstStyle/>
  <a:p>
    <a:r>
      <a:rPr lang="en-US" dirty="0" smtClean="0">
        <a:latin typeface="Verdana"/>
        <a:cs typeface="Verdana"/>
      </a:rPr>
      <a:t>A textbox with Verdana typeface applied to shape, not text selection</a:t>
    </a:r>
    <a:endParaRPr lang="en-US" dirty="0">
      <a:latin typeface="Verdana"/>
      <a:cs typeface="Verdana"/>
    </a:endParaRPr>
  </a:p>
</p:txBody>

textbox with multiple runs, typeface applied at shape level:

<p:txBody>
  <a:bodyPr wrap="none" rtlCol="0">
    <a:spAutoFit/>
  </a:bodyPr>
  <a:lstStyle/>
  <a:p>
    <a:pPr algn="ctr"/>
    <a:r>
      <a:rPr lang="en-US" dirty="0" smtClean="0">
        <a:latin typeface="Arial Black"/>
        <a:cs typeface="Arial Black"/>
      </a:rPr>
      <a:t>textbox with multiple runs having typeface</a:t>
    </a:r>
    <a:br>
      <a:rPr lang="en-US" dirty="0" smtClean="0">
        <a:latin typeface="Arial Black"/>
        <a:cs typeface="Arial Black"/>
      </a:rPr>
    </a:br>
    <a:r>
      <a:rPr lang="en-US" dirty="0" smtClean="0">
        <a:latin typeface="Arial Black"/>
        <a:cs typeface="Arial Black"/>
      </a:rPr>
      <a:t>customized at shape level</a:t>
    </a:r>
    <a:endParaRPr lang="en-US" dirty="0">
      <a:latin typeface="Arial Black"/>
      <a:cs typeface="Arial Black"/>
    </a:endParaRPr>
  </a:p>
</p:txBody>

Asian characters, or possibly Asian font being applied:

<p:txBody>
  <a:bodyPr wrap="none" rtlCol="0">
    <a:spAutoFit/>
  </a:bodyPr>
  <a:lstStyle/>
  <a:p>
    <a:pPr algn="ctr"/>
    <a:r>
      <a:rPr lang="en-US" dirty="0" smtClean="0">
        <a:latin typeface="Hiragino Sans GB W3"/>
        <a:ea typeface="Hiragino Sans GB W3"/>
        <a:cs typeface="Hiragino Sans GB W3"/>
      </a:rPr>
      <a:t>暒龢加咊晴弗</a:t>
    </a:r>
    <a:endParaRPr lang="en-US" dirty="0">
      <a:latin typeface="Hiragino Sans GB W3"/>
      <a:ea typeface="Hiragino Sans GB W3"/>
      <a:cs typeface="Hiragino Sans GB W3"/>
    </a:endParaRPr>
  </a:p>
</p:txBody>

then applying Arial from font pull-down:

<p:txBody>
  <a:bodyPr wrap="none" rtlCol="0">
    <a:spAutoFit/>
  </a:bodyPr>
  <a:lstStyle/>
  <a:p>
    <a:pPr algn="ctr"/>
    <a:r>
      <a:rPr lang="en-US" dirty="0" smtClean="0">
        <a:latin typeface="Arial"/>
        <a:ea typeface="Hiragino Sans GB W3"/>
        <a:cs typeface="Arial"/>
      </a:rPr>
      <a:t>暒龢加咊晴弗</a:t>
    </a:r>
    <a:endParaRPr lang="en-US" dirty="0">
      <a:latin typeface="Arial"/>
      <a:ea typeface="Hiragino Sans GB W3"/>
      <a:cs typeface="Arial"/>
    </a:endParaRPr>
  </a:p>
</p:txBody>

Observations

  • PowerPoint UI always applies typeface customization at run level rather than paragraph (defRPr) level, even when applied to shape rather than a specific selection of text.
  • PowerPoint applies the same typeface to the <a:latin> and <a:cs> tag when a typeface is selected from the font pull-down in the UI.