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

Function test_fontname

tests/test_font.py:48–59  ·  view source on GitHub ↗

Assert a valid PDF fontname.

()

Source from the content-addressed store, hash-verified

46
47
48def test_fontname():
49 """Assert a valid PDF fontname."""
50 doc = pymupdf.open()
51 page = doc.new_page()
52 assert page.insert_font() # assert: a valid fontname works!
53 detected = False # preset indicator
54 try: # fontname check will fail first - don't need a font at all here
55 page.insert_font(fontname="illegal/char", fontfile="unimportant")
56 except ValueError as e:
57 if str(e).startswith("bad fontname chars"):
58 detected = True # illegal fontname detected
59 assert detected
60
61def test_2608():
62 flags = (pymupdf.TEXT_DEHYPHENATE | pymupdf.TEXT_MEDIABOX_CLIP)

Callers

nothing calls this directly

Calls 2

new_pageMethod · 0.80
insert_fontMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…