10000 Deprecate dviread.Encoding. by anntzer · Pull Request #16596 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

Deprecate dviread.Encoding. #16596

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 11, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions doc/api/next_api_changes/deprecations.rst
Original file line number Diff line number Diff line change
Expand Up @@ -307,3 +307,7 @@ The *quality*, *optimize*, and *progressive* keyword arguments to

Such options should now be directly passed to Pillow using
``savefig(..., pil_kwargs={"quality": ..., "optimize": ..., "progressive": ...})``.

``dviread.Encoding``
~~~~~~~~~~~~~~~~~~~~
This class was (mostly) broken and is deprecated.
11 changes: 5 additions & 6 deletions lib/matplotlib/backends/backend_pdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -763,12 +763,11 @@ def _embedTeXFont(self, fontinfo):

# Encoding (if needed)
if fontinfo.encodingfile is not None:
enc = dviread.Encoding(fontinfo.encodingfile)
differencesArray = [Name(ch) for ch in enc]
differencesArray = [0] + differencesArray
fontdict['Encoding'] = \
{'Type': Name('Encoding'),
'Differences': differencesArray}
fontdict['Encoding'] = {
'Type': Name('Encoding'),
'Differences': [
0, *map(Name, dviread._parse_enc(fontinfo.encodingfile))],
}

# If no file is specified, stop short
if fontinfo.fontfile is None:
Expand Down
4 changes: 2 additions & 2 deletions lib/matplotlib/dviread.py
Original file line number Diff line number Diff line change
Expand Up @@ -919,6 +919,7 @@ def _parse(self, file):
encoding=encoding, filename=filename)


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