Ensure correct calculation of fitting text.
()
| 135 | |
| 136 | |
| 137 | def test_2637(): |
| 138 | """Ensure correct calculation of fitting text.""" |
| 139 | doc = pymupdf.open() |
| 140 | page = doc.new_page() |
| 141 | text = ( |
| 142 | "The morning sun painted the sky with hues of orange and pink. " |
| 143 | "Birds chirped harmoniously, greeting the new day. " |
| 144 | "Nature awakened, filling the air with life and promise." |
| 145 | ) |
| 146 | rect = pymupdf.Rect(50, 50, 500, 280) |
| 147 | fontsize = 50 |
| 148 | rc = -1 |
| 149 | while rc < 0: # look for largest font size that makes the text fit |
| 150 | rc = page.insert_textbox(rect, text, fontname="hebo", fontsize=fontsize) |
| 151 | fontsize -= 1 |
| 152 | |
| 153 | # confirm text won't lap outside rect |
| 154 | blocks = page.get_text("blocks") |
| 155 | bbox = pymupdf.Rect(blocks[0][:4]) |
| 156 | assert bbox in rect |
| 157 | |
| 158 | |
| 159 | def test_htmlbox1(): |
nothing calls this directly
no test coverage detected
searching dependent graphs…