Skip to content

Commit 0abc553

Browse files
authored
Merge pull request matplotlib#16596 from anntzer/unenc
Deprecate dviread.Encoding.
2 parents 623851f + 017922c commit 0abc553

File tree

3 files changed

+11
-8
lines changed

3 files changed

+11
-8
lines changed

doc/api/next_api_changes/deprecations.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,3 +307,7 @@ The *quality*, *optimize*, and *progressive* keyword arguments to
307307

308308
Such options should now be directly passed to Pillow using
309309
``savefig(..., pil_kwargs={"quality": ..., "optimize": ..., "progressive": ...})``.
310+
311+
``dviread.Encoding``
312+
~~~~~~~~~~~~~~~~~~~~
313+
This class was (mostly) broken and is deprecated.

lib/matplotlib/backends/backend_pdf.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -763,12 +763,11 @@ def _embedTeXFont(self, fontinfo):
763763

764764
# Encoding (if needed)
765765
if fontinfo.encodingfile is not None:
766-
enc = dviread.Encoding(fontinfo.encodingfile)
767-
differencesArray = [Name(ch) for ch in enc]
768-
differencesArray = [0] + differencesArray
769-
fontdict['Encoding'] = \
770-
{'Type': Name('Encoding'),
771-
'Differences': differencesArray}
766+
fontdict['Encoding'] = {
767+
'Type': Name('Encoding'),
768+
'Differences': [
769+
0, *map(Name, dviread._parse_enc(fontinfo.encodingfile))],
770+
}
772771

773772
# If no file is specified, stop short
774773
if fontinfo.fontfile is None:

lib/matplotlib/dviread.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -919,6 +919,7 @@ def _parse(self, file):
919919
encoding=encoding, filename=filename)
920920

921921

922+
@cbook.deprecated("3.3")
922923
class Encoding:
923924
r"""
924925
Parses a \*.enc file referenced from a psfonts.map style file.
@@ -988,8 +989,7 @@ def _parse_enc(path):
988989
The nth entry of the list is the PostScript glyph name of the nth
989990
glyph.
990991
"""
991-
with open(path, encoding="ascii") as file:
992-
no_comments = "\n".join(line.split("%")[0].rstrip() for line in file)
992+
no_comments = re.sub("%.*", "", Path(path).read_text(encoding="ascii"))
993993
array = re.search(r"(?s)\[(.*)\]", no_comments).group(1)
994994
lines = [line for line in array.split() if line]
995995
if all(line.startswith("/") for line in lines):

0 commit comments

Comments
 (0)