Skip to content
Open
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
8 changes: 4 additions & 4 deletions lib/matplotlib/_type1font.py
Original file line number Diff line number Diff line change
Expand Up @@ -866,17 +866,16 @@ def subset(self, characters, name_prefix):
encoding = {code: glyph
for code, glyph in self.prop['Encoding'].items()
if code in characters}
encoding[0] = '.notdef'
# todo and done include strings (glyph names)
todo = set(encoding.values())
todo = {'.notdef', *encoding.values()}
done = set()
seen_subrs = {0, 1, 2, 3}
while todo:
glyph = todo.pop()
called_glyphs, called_subrs = _CharstringSimulator(self).run(glyph)
done.add(glyph)
todo.update(called_glyphs - done)
seen_subrs.update(called_subrs)
done.add(glyph)

charstrings = self._subset_charstrings(done)
subrs = self._subset_subrs(seen_subrs)
Expand Down Expand Up @@ -949,7 +948,8 @@ def _charstring_tokens(data):
def _postscript_encoding(self, encoding):
"""Return a PostScript encoding array for the encoding."""
return '\n'.join([
'/Encoding 256 array\n0 1 255 { 1 index exch /.notdef put} for',
'/Encoding 256 array',
'0 1 255 { 1 index exch /.notdef put} for',
*(
f'dup {i} /{glyph} put'
for i, glyph in sorted(encoding.items())
Expand Down
Binary file modified lib/matplotlib/tests/baseline_images/test_usetex/test_usetex.pdf
Binary file not shown.
Binary file modified lib/matplotlib/tests/baseline_images/test_usetex/test_usetex.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 4 additions & 3 deletions lib/matplotlib/tests/test_usetex.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,12 @@ def test_usetex():
kwargs = {"verticalalignment": "baseline", "size": 24,
"bbox": dict(pad=0, edgecolor="k", facecolor="none")}
ax.text(0.2, 0.7,
# the \LaTeX macro exercises character sizing and placement,
# The \LaTeX macro exercises character sizing and placement,
# \left[ ... \right\} draw some variable-height characters,
# \sqrt and \frac draw horizontal rules, \mathrm changes the font
# \sqrt and \frac draw horizontal rules, \mathrm changes the font,
# the minus sign hits character code 0 in the Type 1 font that LaTeX uses.
r'\LaTeX\ $\left[\int\limits_e^{2e}'
r'\sqrt\frac{\log^3 x}{x}\,\mathrm{d}x \right\}$',
r'-\sqrt\frac{\log^3 x}{x}\,\mathrm{d}x \right\}$',
**kwargs)
ax.text(0.2, 0.3, "lg", **kwargs)
ax.text(0.4, 0.3, r"$\frac{1}{2}\pi$", **kwargs)
Expand Down
Loading