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

Function test_subset_fonts

tests/test_general.py:777–798  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

775
776
777def test_subset_fonts():
778 if os.environ.get('PYODIDE_ROOT'):
779 print('test_subset_fonts(): not running on Pyodide - ValueError: No font code \'ubuntu\' found in pymupdf-fonts.')
780 return
781 """Confirm subset_fonts is working."""
782 if not hasattr(pymupdf, "mupdf"):
783 print("Not testing 'test_subset_fonts' in classic.")
784 return
785 text = "Just some arbitrary text."
786 arch = pymupdf.Archive()
787 css = pymupdf.css_for_pymupdf_font("ubuntu", archive=arch)
788 css += "* {font-family: ubuntu;}"
789 doc = pymupdf.open()
790 page = doc.new_page()
791 page.insert_htmlbox(page.rect, text, css=css, archive=arch)
792 doc.subset_fonts(verbose=True)
793 found = False
794 for xref in range(1, doc.xref_length()):
795 if "+Ubuntu#20Regular" in doc.xref_object(xref):
796 found = True
797 break
798 assert found is True
799
800
801def test_2957_1():

Callers

nothing calls this directly

Calls 6

new_pageMethod · 0.80
insert_htmlboxMethod · 0.80
subset_fontsMethod · 0.80
xref_lengthMethod · 0.80
xref_objectMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…