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

Skip to content

Commit 4a5c982

Browse files
committed
Fix for STIX fonts with PDF backend.
svn path=/trunk/matplotlib/; revision=4498
1 parent dbe0f68 commit 4a5c982

1 file changed

Lines changed: 17 additions & 16 deletions

File tree

lib/matplotlib/backends/backend_pdf.py

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ def __init__(self, width, height, filename):
334334
self.passed_in_file_object = True
335335
else:
336336
raise ValueError("filename must be a path or a file-like object")
337-
337+
338338
self.fh = fh
339339
self.currentstream = None # stream object to write to, if any
340340
fh.write("%PDF-1.4\n") # 1.4 is the first version to have alpha
@@ -524,7 +524,7 @@ def embedType1(self, filename, fontinfo):
524524

525525
firstchar = 0
526526
lastchar = len(fontinfo.widths) - 1
527-
527+
528528
fontdict = {
529529
'Type': Name('Font'),
530530
'Subtype': Name('Type1'),
@@ -569,7 +569,7 @@ def embedType1(self, filename, fontinfo):
569569
'XHeight': 500, # TODO: this one too
570570
'FontFile': fontfileObject,
571571
'FontFamily': familyname,
572-
'StemV': 50, # TODO
572+
'StemV': 50, # TODO
573573
# (see also revision 3874; but not all TeX distros have AFM files!)
574574
#'FontWeight': a number where 400 = Regular, 700 = Bold
575575
}
@@ -614,7 +614,7 @@ def _get_xobject_symbol_name(self, filename, symbol_name):
614614
CMapName currentdict /CMap defineresource pop
615615
end
616616
end"""
617-
617+
618618
def embedTTF(self, filename, characters):
619619
"""Embed the TTF font from the named file into the document."""
620620

@@ -713,7 +713,7 @@ def get_char_width(charcode):
713713
charprocDict['Type'] = Name('XObject')
714714
charprocDict['Subtype'] = Name('Form')
715715
charprocDict['BBox'] = bbox
716-
charprocObject = self.reserveObject('charProc for %s' % name)
716+
charprocObject = self.reserveObject('charProc')
717717
self.beginStream(charprocObject.id, None, charprocDict)
718718
self.currentstream.write(stream)
719719
self.endStream()
@@ -827,7 +827,7 @@ def embedTTFType42(font, characters, descriptor):
827827
unicode_cmap = (self._identityToUnicodeCMap %
828828
(len(unicode_groups),
829829
"\n".join(unicode_bfrange)))
830-
830+
831831
# CIDToGIDMap stream
832832
cid_to_gid_map = "".join(cid_to_gid_map).encode("utf-16be")
833833
self.beginStream(cidToGidMapObject.id,
@@ -842,7 +842,7 @@ def embedTTFType42(font, characters, descriptor):
842842
{'Length': unicode_cmap})
843843
self.currentstream.write(unicode_cmap)
844844
self.endStream()
845-
845+
846846
descriptor['MaxWidth'] = max_width
847847

848848
# Write everything out
@@ -896,7 +896,7 @@ def embedTTFType42(font, characters, descriptor):
896896
warnings.warn(("'%s' can not be subsetted into a Type 3 font. " +
897897
"The entire font will be embedded in the output.") %
898898
os.path.basename(filename))
899-
899+
900900
if fonttype == 3:
901901
return embedTTFType3(font, characters, descriptor)
902902
elif fonttype == 42:
@@ -1378,7 +1378,7 @@ def draw_mathtext(self, gc, x, y, s, prop, angle):
13781378
fonttype = 42
13791379
else:
13801380
fonttype = global_fonttype
1381-
1381+
13821382
if fonttype == 42 or num <= 255:
13831383
self._setup_textpos(ox, oy, 0, oldx, oldy)
13841384
oldx, oldy = ox, oy
@@ -1397,8 +1397,9 @@ def draw_mathtext(self, gc, x, y, s, prop, angle):
13971397
fonttype = 42
13981398
else:
13991399
fonttype = global_fonttype
1400-
1400+
14011401
if fonttype == 3 and num > 255:
1402+
self.file.fontName(fontname)
14021403
self.file.output(Op.gsave,
14031404
0.001 * fontsize, 0,
14041405
0, 0.001 * fontsize,
@@ -1534,12 +1535,12 @@ def draw_text(self, gc, x, y, s, prop, angle, ismath=False):
15341535
y += font.get_descent() / 64.0
15351536

15361537
fonttype = rcParams['pdf.fonttype']
1537-
1538+
15381539
# We can't subset all OpenType fonts, so switch to Type 42
15391540
# in that case.
15401541
if is_opentype_cff_font(font.fname):
15411542
fonttype = 42
1542-
1543+
15431544
def check_simple_method(s):
15441545
"""Determine if we should use the simple or woven method
15451546
to output this text, and chunks the string into 1-byte and
@@ -1830,7 +1831,7 @@ def clip_cmd(self, cliprect, clippath):
18301831
if (self._cliprect, self._clippath) != (cliprect, clippath):
18311832
cmds.extend(self.push())
18321833
if self._cliprect != cliprect:
1833-
cmds.extend([t for t in cliprect] +
1834+
cmds.extend([t for t in cliprect] +
18341835
[Op.rectangle, Op.clip, Op.endpath])
18351836
if self._clippath != clippath:
18361837
cmds.extend(PdfFile.pathOperations(clippath) +
@@ -1858,7 +1859,7 @@ def delta(self, other):
18581859
"""
18591860
cmds = []
18601861
for params, cmd in self.commands:
1861-
ours = [ getattr(self, p) for p in params ]
1862+
ours = [ getattr(self, p) for p in params ]
18621863
theirs = [ getattr(other, p) for p in params ]
18631864
if ours != theirs:
18641865
cmds.extend(cmd(self, *theirs))
@@ -1919,10 +1920,10 @@ def draw(self):
19191920
pass
19201921

19211922
filetypes = {'pdf': 'Portable Document Format'}
1922-
1923+
19231924
def get_default_filetype(self):
19241925
return 'pdf'
1925-
1926+
19261927
def print_pdf(self, filename, **kwargs):
19271928
dpi = kwargs.get('dpi', None)
19281929
self.figure.set_dpi(72) # Override the dpi kwarg

0 commit comments

Comments
 (0)