Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 138d959

Browse files
committed
Fix including Type 42 fonts in PDF on Python 3.x
1 parent 1909fef commit 138d959

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

lib/matplotlib/backends/backend_pdf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -970,7 +970,7 @@ def embedTTFType42(font, characters, descriptor):
970970
" ".join(["<%04x>" % x for x in range(start, end+1)])))
971971
unicode_cmap = (self._identityToUnicodeCMap %
972972
(len(unicode_groups),
973-
"\n".join(unicode_bfrange)))
973+
"\n".join(unicode_bfrange))).encode('ascii')
974974

975975
# CIDToGIDMap stream
976976
cid_to_gid_map = "".join(cid_to_gid_map).encode("utf-16be")

lib/matplotlib/tests/test_backend_pdf.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,15 @@ def test_use14corefonts():
2222
plt.title(title)
2323
plt.text(0.5, 0.5, text, horizontalalignment='center', fontsize=24)
2424
plt.axhline(0.5, linewidth=0.5)
25+
26+
27+
def test_type42():
28+
import io
29+
30+
rcParams['backend'] = 'pdf'
31+
rcParams['pdf.fonttype'] = 42
32+
33+
fig = plt.figure()
34+
ax = fig.add_subplot(111)
35+
ax.plot([1,2,3])
36+
fig.savefig(io.BytesIO())

0 commit comments

Comments
 (0)