Increase or decrease the current font size of all runs in a shape by `delta` points. If a run has no explicitly set font size (font.size is None), we can either skip it or assume a default. For simplicity, let's skip runs without an explicit size to avoid overwriting theme defaults.
(shape, delta=2)
| 1661 | text_frame.margin_left = Pt(_px_to_pt(left_px)) |
| 1662 | |
| 1663 | def adjust_font_size(shape, delta=2): |
| 1664 | """ |
| 1665 | Increase or decrease the current font size of all runs in a shape by `delta` points. |
| 1666 | If a run has no explicitly set font size (font.size is None), we can either skip it or assume a default. |
| 1667 | For simplicity, let's skip runs without an explicit size to avoid overwriting theme defaults. |
| 1668 | |
| 1669 | :param shape: The textbox shape to update. |
| 1670 | :param delta: Positive or negative integer to adjust the font size. |
| 1671 | """ |
| 1672 | text_frame = shape.text_frame |
| 1673 | text_frame.auto_size = MSO_AUTO_SIZE.NONE |
| 1674 | for paragraph in text_frame.paragraphs: |
| 1675 | for run in paragraph.runs: |
| 1676 | current_size = run.font.size |
| 1677 | if current_size is not None: |
| 1678 | new_size = current_size.pt + delta |
| 1679 | # Prevent negative or zero font size |
| 1680 | if new_size < 1: |
| 1681 | new_size = 1 |
| 1682 | run.font.size = Pt(new_size) |
| 1683 | |
| 1684 | def center_shape_horizontally(prs, shape): |
| 1685 | """ |
nothing calls this directly
no outgoing calls
no test coverage detected