MCPcopy Create free account
hub / github.com/pymupdf/PyMuPDF / test_2533

Function test_2533

tests/test_general.py:295–318  ·  view source on GitHub ↗

Assert correct char bbox in page.get_texttrace(). Search for a unique char on page and confirm that page.get_texttrace() returns the same bbox as the search method.

()

Source from the content-addressed store, hash-verified

293
294
295def test_2533():
296 """Assert correct char bbox in page.get_texttrace().
297
298 Search for a unique char on page and confirm that page.get_texttrace()
299 returns the same bbox as the search method.
300 """
301 if not pymupdf.g_use_extra:
302 print('Not running test_2533() because use_extra=0 known to fail')
303 return
304 pymupdf.TOOLS.set_small_glyph_heights(True)
305 try:
306 doc = pymupdf.open(os.path.join(scriptdir, "resources", "test_2533.pdf"))
307 page = doc[0]
308 NEEDLE = "民"
309 ord_NEEDLE = ord(NEEDLE)
310 for span in page.get_texttrace():
311 for char in span["chars"]:
312 if char[0] == ord_NEEDLE:
313 bbox = pymupdf.Rect(char[3])
314 break
315 bbox2 = page.search_for(NEEDLE)[0]
316 assert bbox2 == bbox, f'{bbox=} {bbox2=} {bbox2-bbox=}.'
317 finally:
318 pymupdf.TOOLS.set_small_glyph_heights(False)
319
320
321def test_2645():

Callers

nothing calls this directly

Calls 3

get_texttraceMethod · 0.80
search_forMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…