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

Class ShapeData

pptx/scripts/inventory.py:266–739  ·  view source on GitHub ↗

Data structure for shape properties extracted from a PowerPoint shape.

Source from the content-addressed store, hash-verified

264
265
266class ShapeData:
267 """Data structure for shape properties extracted from a PowerPoint shape."""
268
269 @staticmethod
270 def emu_to_inches(emu: int) -> float:
271 """Convert EMUs (English Metric Units) to inches."""
272 return emu / 914400.0
273
274 @staticmethod
275 def inches_to_pixels(inches: float, dpi: int = 96) -> int:
276 """Convert inches to pixels at given DPI."""
277 return int(inches * dpi)
278
279 @staticmethod
280 def get_font_path(font_name: str) -> Optional[str]:
281 """Get the font file path for a given font name.
282
283 Args:
284 font_name: Name of the font (e.g., 'Arial', 'Calibri')
285
286 Returns:
287 Path to the font file, or None if not found
288 """
289 system = platform.system()
290
291 # Common font file variations to try
292 font_variations = [
293 font_name,
294 font_name.lower(),
295 font_name.replace(" ", ""),
296 font_name.replace(" ", "-"),
297 ]
298
299 # Define font directories and extensions by platform
300 if system == "Darwin": # macOS
301 font_dirs = [
302 "/System/Library/Fonts/",
303 "/Library/Fonts/",
304 "~/Library/Fonts/",
305 ]
306 extensions = [".ttf", ".otf", ".ttc", ".dfont"]
307 else: # Linux
308 font_dirs = [
309 "/usr/share/fonts/truetype/",
310 "/usr/local/share/fonts/",
311 "~/.fonts/",
312 ]
313 extensions = [".ttf", ".otf"]
314
315 # Try to find the font file
316 from pathlib import Path
317
318 for font_dir in font_dirs:
319 font_dir_path = Path(font_dir).expanduser()
320 if not font_dir_path.exists():
321 continue
322
323 # First try exact matches

Callers 1

extract_text_inventoryFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected