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)
| 1225 | |
| 1226 | |
| 1227 | def _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 | |
| 1251 | class _LuatexKpsewhich: |
no test coverage detected
searching dependent graphs…