SourceForge logo
SourceForge logo
Menu

matplotlib-devel

From: Michael D. <md...@st...> - 2007年06月27日 20:24:13
I have a patch for this bug that prevents PDF writing on Python 2.5 (I 
think OS X is a red herring in the bug report -- I was having the same 
problem on Linux). Python 2.5 changed from 
encodings.cp1252.encoding_map (a dictionary) to 
encodings.cp1252.encoding_table (a tuple).
http://sourceforge.net/tracker/index.php?func=detail&aid=1738494&group_id=80706&atid=560720 
Cheers,
Mike
I have a patch for this bug that prevents PDF writing on Python 2.5 (I 
think OS X is a red herring in the bug report -- I was having the same 
problem on Linux). Python 2.5 changed from 
encodings.cp1252.encoding_map (a dictionary) to 
encodings.cp1252.encoding_table (a tuple), and this updates matplotlib 
to use whatever is available.
http://sourceforge.net/tracker/index.php?func=detail&aid=1738494&group_id=80706&atid=560720 
Cheers,
Mike
------------------------------------------------------------------------
Index: backend_pdf.py
===================================================================
--- backend_pdf.py	(revision 3418)
+++ backend_pdf.py	(working copy)
@@ -500,11 +500,20 @@
 # composite font, based on multi-byte characters.
 
 from encodings import cp1252
- firstchar, lastchar = 0, 255
+ # The "decoding_map" was changed to a "decoding_table" as of Python 2.5.
+ if hasattr(cp1252, 'decoding_map'):
+ def decode_char(charcode):
+ return cp1252.decoding_map[charcode] or 0
+ else:
+ def decode_char(charcode):
+ return ord(cp1252.decoding_table[charcode]) or 0
+
 def get_char_width(charcode):
- unicode = cp1252.decoding_map[charcode] or 0
+ unicode = decode_char(charcode)
 width = font.load_char(unicode, flags=LOAD_NO_SCALE).horiAdvance
 return cvt(width)
+
+ firstchar, lastchar = 0, 255
 widths = [ get_char_width(charcode) for charcode in range(firstchar, lastchar+1) ]
 
 widthsObject = self.reserveObject('font widths')
------------------------------------------------------------------------
Index: backend_pdf.py
===================================================================
--- backend_pdf.py	(revision 3418)
+++ backend_pdf.py	(working copy)
@@ -500,11 +500,20 @@
 # composite font, based on multi-byte characters.
 
 from encodings import cp1252
- firstchar, lastchar = 0, 255
+ # The "decoding_map" was changed to a "decoding_table" as of Python 2.5.
+ if hasattr(cp1252, 'decoding_map'):
+ def decode_char(charcode):
+ return cp1252.decoding_map[charcode] or 0
+ else:
+ def decode_char(charcode):
+ return ord(cp1252.decoding_table[charcode]) or 0
+
 def get_char_width(charcode):
- unicode = cp1252.decoding_map[charcode] or 0
+ unicode = decode_char(charcode)
 width = font.load_char(unicode, flags=LOAD_NO_SCALE).horiAdvance
 return cvt(width)
+
+ firstchar, lastchar = 0, 255
 widths = [ get_char_width(charcode) for charcode in range(firstchar, lastchar+1) ]
 
 widthsObject = self.reserveObject('font widths')
From: John H. <jd...@gm...> - 2007年06月27日 20:36:51
On 6/27/07, Michael Droettboom <md...@st...> wrote:
> I have a patch for this bug that prevents PDF writing on Python 2.5 (I
> think OS X is a red herring in the bug report -- I was having the same
> problem on Linux). Python 2.5 changed from
> encodings.cp1252.encoding_map (a dictionary) to
> encodings.cp1252.encoding_table (a tuple).
>
> http://sourceforge.net/tracker/index.php?func=detail&aid=1738494&group_id=80706&atid=560720
>
>
It looks like your patch has some line wrapping issues -- could you
also attach the patch?
Thanks,
JDH
From: Michael D. <md...@st...> - 2007年06月27日 21:00:07
Attachments: 1738494.patch
John Hunter wrote:
> It looks like your patch has some line wrapping issues -- could you
> also attach the patch?
Here it is.
Cheers,
Mike
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.
Thanks for helping keep SourceForge clean.
X





Briefly describe the problem (required):
Upload screenshot of ad (required):
Select a file, or drag & drop file here.
Screenshot instructions:

Click URL instructions:
Right-click on the ad, choose "Copy Link", then paste here →
(This may not be possible with some types of ads)

More information about our ad policies

Ad destination/click URL:

AltStyle によって変換されたページ (->オリジナル) /