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

Function get_old_widths

src_classic/utils.py:5179–5195  ·  view source on GitHub ↗

Retrieve old font '/W' and '/DW' values.

(xref)

Source from the content-addressed store, hash-verified

5177 font_buffers = {}
5178
5179 def get_old_widths(xref):
5180 """Retrieve old font '/W' and '/DW' values."""
5181 df = doc.xref_get_key(xref, "DescendantFonts")
5182 if df[0] != "array": # only handle xref specifications
5183 return None, None
5184 df_xref = int(df[1][1:-1].replace("0 R", ""))
5185 widths = doc.xref_get_key(df_xref, "W")
5186 if widths[0] != "array": # no widths key found
5187 widths = None
5188 else:
5189 widths = widths[1]
5190 dwidths = doc.xref_get_key(df_xref, "DW")
5191 if dwidths[0] != "int":
5192 dwidths = None
5193 else:
5194 dwidths = dwidths[1]
5195 return widths, dwidths
5196
5197 def set_old_widths(xref, widths, dwidths):
5198 """Restore the old '/W' and '/DW' in subsetted font.

Callers 2

subset_fontsMethod · 0.85
subset_fontsFunction · 0.85

Calls 1

xref_get_keyMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…