MCPcopy Create free account
hub / github.com/SpaceZephyr/myskill / _get_default_font_size

Method _get_default_font_size

pptx/scripts/inventory.py:480–507  ·  view source on GitHub ↗

Get default font size from theme text styles or use conservative default.

(self)

Source from the content-addressed store, hash-verified

478 return paragraphs
479
480 def _get_default_font_size(self) -> int:
481 """Get default font size from theme text styles or use conservative default."""
482 try:
483 if not (
484 hasattr(self.shape, "part") and hasattr(self.shape.part, "slide_layout")
485 ):
486 return 14
487
488 slide_master = self.shape.part.slide_layout.slide_master # type: ignore
489 if not hasattr(slide_master, "element"):
490 return 14
491
492 # Determine theme style based on placeholder type
493 style_name = "bodyStyle" # Default
494 if self.placeholder_type and "TITLE" in self.placeholder_type:
495 style_name = "titleStyle"
496
497 # Find font size in theme styles
498 for child in slide_master.element.iter():
499 tag = child.tag.split("}")[-1] if "}" in child.tag else child.tag
500 if tag == style_name:
501 for elem in child.iter():
502 if "sz" in elem.attrib:
503 return int(elem.attrib["sz"]) // 100
504 except Exception:
505 pass
506
507 return 14 # Conservative default for body text
508
509 def _get_usable_dimensions(self, text_frame) -> Tuple[int, int]:
510 """Get usable width and height in pixels after accounting for margins."""

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected