|
From: <md...@us...> - 2007-08-09 15:15:10
|
Revision: 3695
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=3695&view=rev
Author: mdboom
Date: 2007-08-09 08:14:59 -0700 (Thu, 09 Aug 2007)
Log Message:
-----------
Minor PDF filesize improvement.
Modified Paths:
--------------
trunk/matplotlib/lib/matplotlib/backends/backend_pdf.py
Modified: trunk/matplotlib/lib/matplotlib/backends/backend_pdf.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/backends/backend_pdf.py 2007-08-09 15:14:28 UTC (rev 3694)
+++ trunk/matplotlib/lib/matplotlib/backends/backend_pdf.py 2007-08-09 15:14:59 UTC (rev 3695)
@@ -508,6 +508,7 @@
charprocsObject = self.reserveObject('character procs')
differencesArray = []
firstchar, lastchar = 0, 255
+ bbox = [cvt(x, nearest=False) for x in font.bbox]
fontdict = {
'Type' : Name('Font'),
@@ -517,7 +518,7 @@
'FontDescriptor' : fontdescObject,
'Subtype' : Name('Type3'),
'Name' : descriptor['FontName'],
- 'FontBBox' : [cvt(x, nearest=False) for x in font.bbox],
+ 'FontBBox' : bbox,
'FontMatrix' : [ .001, 0, 0, .001, 0, 0 ],
'CharProcs' : charprocsObject,
'Encoding' : {
@@ -575,15 +576,18 @@
charprocs = {}
charprocsRef = {}
for charname, stream in rawcharprocs.items():
+ charprocDict = { 'Length': len(stream) }
+ # The 2-byte characters are used as XObjects, so they
+ # need extra info in their dictionary
+ if charname in two_byte_chars:
+ charprocDict['Type'] = Name('XObject')
+ charprocDict['Subtype'] = Name('Form')
+ charprocDict['BBox'] = bbox
charprocObject = self.reserveObject('charProc for %s' % name)
- self.beginStream(charprocObject.id,
- None,
- {'Length': len(stream),
- 'Type': Name('XObject'),
- 'Subtype': Name('Form'),
- 'BBox': [cvt(x, nearest=False) for x in font.bbox]})
+ self.beginStream(charprocObject.id, None, charprocDict)
self.currentstream.write(stream)
self.endStream()
+
# Send the glyphs with ccode > 255 to the XObject dictionary,
# and the others to the font itself
if charname in two_byte_chars:
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|