@@ -5538,7 +5538,7 @@ def recover_char_quad(line_dir: tuple, span: dict, char: dict) -> pymupdf.Quad:
5538
5538
# -------------------------------------------------------------------
5539
5539
# Building font subsets using fontTools
5540
5540
# -------------------------------------------------------------------
5541
- def subset_fonts (doc : pymupdf .Document , verbose : bool = False , fallback : bool = False ) -> None :
5541
+ def subset_fonts (doc : pymupdf .Document , verbose : bool = False , fallback : bool = False ) -> OptInt :
5542
5542
"""Build font subsets in a PDF.
5543
5543
5544
5544
Eligible fonts are potentially replaced by smaller versions. Page text is
@@ -5549,6 +5549,16 @@ def subset_fonts(doc: pymupdf.Document, verbose: bool = False, fallback: bool =
5549
5549
fonts. As this is a new function, errors may still occur. In this case,
5550
5550
please fall back to using the previous version by using "fallback=True".
5551
5551
Fallback mode requires the external package 'fontTools'.
5552
+
5553
+ Args:
5554
+ fallback: use the older deprecated implementation.
5555
+ verbose: only used by fallback mode.
5556
+
5557
+ Returns:
5558
+ The new MuPDF-based code returns None. The deprecated fallback
5559
+ mode returns 0 if there are no fonts to subset. Otherwise, it
5560
+ returns the decrease in fontsize (the difference in fontsize),
5561
+ measured in bytes.
5552
5562
"""
5553
5563
# Font binaries: - "buffer" -> (names, xrefs, (unicodes, glyphs))
5554
5564
# An embedded font is uniquely defined by its fontbuffer only. It may have
0 commit comments