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

Method _get_usable_dimensions

pptx/scripts/inventory.py:509–532  ·  view source on GitHub ↗

Get usable width and height in pixels after accounting for margins.

(self, text_frame)

Source from the content-addressed store, hash-verified

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."""
511 # Default PowerPoint margins in inches
512 margins = {"top": 0.05, "bottom": 0.05, "left": 0.1, "right": 0.1}
513
514 # Override with actual margins if set
515 if hasattr(text_frame, "margin_top") and text_frame.margin_top:
516 margins["top"] = self.emu_to_inches(text_frame.margin_top)
517 if hasattr(text_frame, "margin_bottom") and text_frame.margin_bottom:
518 margins["bottom"] = self.emu_to_inches(text_frame.margin_bottom)
519 if hasattr(text_frame, "margin_left") and text_frame.margin_left:
520 margins["left"] = self.emu_to_inches(text_frame.margin_left)
521 if hasattr(text_frame, "margin_right") and text_frame.margin_right:
522 margins["right"] = self.emu_to_inches(text_frame.margin_right)
523
524 # Calculate usable area
525 usable_width = self.width - margins["left"] - margins["right"]
526 usable_height = self.height - margins["top"] - margins["bottom"]
527
528 # Convert to pixels
529 return (
530 self.inches_to_pixels(usable_width),
531 self.inches_to_pixels(usable_height),
532 )
533
534 def _wrap_text_line(self, line: str, max_width_px: int, draw, font) -> List[str]:
535 """Wrap a single line of text to fit within max_width_px."""

Callers 1

Calls 2

emu_to_inchesMethod · 0.95
inches_to_pixelsMethod · 0.95

Tested by

no test coverage detected