MCPcopy Create free account
hub / github.com/scanny/python-pptx / Font

Class Font

src/pptx/text/text.py:280–422  ·  view source on GitHub ↗

Character properties object, providing font size, font name, bold, italic, etc. Corresponds to `a:rPr` child element of a run. Also appears as `a:defRPr` and `a:endParaRPr` in paragraph and `a:defRPr` in list style elements.

Source from the content-addressed store, hash-verified

278
279
280class Font(object):
281 """Character properties object, providing font size, font name, bold, italic, etc.
282
283 Corresponds to `a:rPr` child element of a run. Also appears as `a:defRPr` and
284 `a:endParaRPr` in paragraph and `a:defRPr` in list style elements.
285 """
286
287 def __init__(self, rPr: CT_TextCharacterProperties):
288 super(Font, self).__init__()
289 self._element = self._rPr = rPr
290
291 @property
292 def bold(self) -> bool | None:
293 """Get or set boolean bold value of |Font|, e.g. `paragraph.font.bold = True`.
294
295 If set to |None|, the bold setting is cleared and is inherited from an enclosing shape's
296 setting, or a setting in a style or master. Returns None if no bold attribute is present,
297 meaning the effective bold value is inherited from a master or the theme.
298 """
299 return self._rPr.b
300
301 @bold.setter
302 def bold(self, value: bool | None):
303 self._rPr.b = value
304
305 @lazyproperty
306 def color(self) -> ColorFormat:
307 """The |ColorFormat| instance that provides access to the color settings for this font."""
308 if self.fill.type != MSO_FILL.SOLID:
309 self.fill.solid()
310 return self.fill.fore_color
311
312 @lazyproperty
313 def fill(self) -> FillFormat:
314 """|FillFormat| instance for this font.
315
316 Provides access to fill properties such as fill color.
317 """
318 return FillFormat.from_fill_parent(self._rPr)
319
320 @property
321 def italic(self) -> bool | None:
322 """Get or set boolean italic value of |Font| instance.
323
324 Has the same behaviors as bold with respect to None values.
325 """
326 return self._rPr.i
327
328 @italic.setter
329 def italic(self, value: bool | None):
330 self._rPr.i = value
331
332 @property
333 def language_id(self) -> MSO_LANGUAGE_ID | None:
334 """Get or set the language id of this |Font| instance.
335
336 The language id is a member of the :ref:`MsoLanguageId` enumeration. Assigning |None|
337 removes any language setting, the same behavior as assigning `MSO_LANGUAGE_ID.NONE`.

Callers 15

fontMethod · 0.90
fontMethod · 0.90
fontMethod · 0.90
fontMethod · 0.90
bold_get_fixtureMethod · 0.90
bold_set_fixtureMethod · 0.90
italic_get_fixtureMethod · 0.90
italic_set_fixtureMethod · 0.90
name_get_fixtureMethod · 0.90
name_set_fixtureMethod · 0.90

Calls

no outgoing calls

Tested by 13

bold_get_fixtureMethod · 0.72
bold_set_fixtureMethod · 0.72
italic_get_fixtureMethod · 0.72
italic_set_fixtureMethod · 0.72
name_get_fixtureMethod · 0.72
name_set_fixtureMethod · 0.72
size_get_fixtureMethod · 0.72
size_set_fixtureMethod · 0.72
underline_get_fixtureMethod · 0.72
underline_set_fixtureMethod · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…