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

Skip to content

Commit 4974261

Browse files
committed
Add prefix to subsetted font names according to PDF spec
1 parent 3bbdc33 commit 4974261

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

lib/matplotlib/backends/backend_pdf.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@
1313
import logging
1414
import math
1515
import os
16+
import random
1617
import re
18+
import string
1719
import struct
1820
import time
1921
import types
@@ -753,6 +755,11 @@ def newTextnote(self, text, positionRect=[-100, -100, 0, 0]):
753755
}
754756
self.pageAnnotations.append(theNote)
755757

758+
def _get_subsetted_psname(self, ps_name):
759+
prefix = "MPL"
760+
rand = ''.join(random.choice(string.ascii_uppercase) for x in range(6))
761+
return prefix + rand + "+" + ps_name
762+
756763
def finalize(self):
757764
"""Write out the various deferred objects and the pdf end matter."""
758765

@@ -1310,7 +1317,8 @@ def embedTTFType42(font, characters, descriptor):
13101317

13111318
# Beginning of main embedTTF function...
13121319

1313-
ps_name = font.postscript_name.encode('ascii', 'replace')
1320+
ps_name = self._get_subsetted_psname(font.postscript_name)
1321+
ps_name = ps_name.encode('ascii', 'replace')
13141322
ps_name = Name(ps_name)
13151323
pclt = font.get_sfnt_table('pclt') or {'capHeight': 0, 'xHeight': 0}
13161324
post = font.get_sfnt_table('post') or {'italicAngle': (0, 0)}

0 commit comments

Comments
 (0)