Skip to content

Commit ebdb8ba

Browse files
cbm755jamie-lemon
authored andcommitted
Document args and return values
1 parent 43a95cb commit ebdb8ba

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/utils.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5538,7 +5538,7 @@ def recover_char_quad(line_dir: tuple, span: dict, char: dict) -> pymupdf.Quad:
55385538
# -------------------------------------------------------------------
55395539
# Building font subsets using fontTools
55405540
# -------------------------------------------------------------------
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:
55425542
"""Build font subsets in a PDF.
55435543
55445544
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 =
55495549
fonts. As this is a new function, errors may still occur. In this case,
55505550
please fall back to using the previous version by using "fallback=True".
55515551
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.
55525562
"""
55535563
# Font binaries: - "buffer" -> (names, xrefs, (unicodes, glyphs))
55545564
# An embedded font is uniquely defined by its fontbuffer only. It may have

0 commit comments

Comments
 (0)