MCPcopy Index your code
hub / github.com/matplotlib/matplotlib / _parse_enc

Function _parse_enc

lib/matplotlib/dviread.py:1227–1248  ·  view source on GitHub ↗

r""" Parse a \*.enc file referenced from a psfonts.map style file. The format supported by this function is a tiny subset of PostScript. Parameters ---------- path : `os.PathLike` Returns ------- list The nth list item is the PostScript glyph name of the nt

(path)

Source from the content-addressed store, hash-verified

1225
1226
1227def _parse_enc(path):
1228 r"""
1229 Parse a \*.enc file referenced from a psfonts.map style file.
1230
1231 The format supported by this function is a tiny subset of PostScript.
1232
1233 Parameters
1234 ----------
1235 path : `os.PathLike`
1236
1237 Returns
1238 -------
1239 list
1240 The nth list item is the PostScript glyph name of the nth glyph.
1241 """
1242 no_comments = re.sub("%.*", "", Path(path).read_text(encoding="ascii"))
1243 array = re.search(r"(?s)\[(.*)\]", no_comments).group(1)
1244 lines = [line for line in array.split() if line]
1245 if all(line.startswith("/") for line in lines):
1246 return [line[1:] for line in lines]
1247 else:
1248 raise ValueError(f"Failed to parse {path} as Postscript encoding")
1249
1250
1251class _LuatexKpsewhich:

Callers 2

glyph_name_or_indexMethod · 0.85

Calls 3

PathClass · 0.85
groupMethod · 0.80
searchMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…