Revision: 6904
          http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6904&view=rev
Author:   jouni
Date:     2009-02-10 22:16:35 +0000 (Tue, 10 Feb 2009)

Log Message:
-----------
Commit Nicolas Grilly's use14corefonts patch

Modified Paths:
--------------
    trunk/matplotlib/CHANGELOG
    trunk/matplotlib/lib/matplotlib/backends/backend_pdf.py

Added Paths:
-----------
    trunk/matplotlib/unit/test_pdf_use14corefonts.py

Modified: trunk/matplotlib/CHANGELOG
===================================================================
--- trunk/matplotlib/CHANGELOG  2009-02-10 16:09:38 UTC (rev 6903)
+++ trunk/matplotlib/CHANGELOG  2009-02-10 22:16:35 UTC (rev 6904)
@@ -1,3 +1,7 @@
+2009-02-10 Fixed a bug in backend_pdf so it doesn't break when the setting
+           pdf.use14corefonts=True is used. Added test case in
+           unit/test_pdf_use14corefonts.py. - NGR
+
 2009-02-08 Added a new imsave function to image.py and exposed it in
            the pyplot interface - GR
 

Modified: trunk/matplotlib/lib/matplotlib/backends/backend_pdf.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/backends/backend_pdf.py     2009-02-10 
16:09:38 UTC (rev 6903)
+++ trunk/matplotlib/lib/matplotlib/backends/backend_pdf.py     2009-02-10 
22:16:35 UTC (rev 6904)
@@ -1465,7 +1465,7 @@
             self.draw_path(boxgc, path, mytrans, gc._rgb)
 
     def encode_string(self, s, fonttype):
-        if fonttype == 3:
+        if fonttype in (1, 3):
             return s.encode('cp1252', 'replace')
         return s.encode('utf-16be', 'replace')
 
@@ -1492,7 +1492,7 @@
             font = self._get_font_afm(prop)
             l, b, w, h = font.get_str_bbox(s)
             descent = -b * fontsize / 1000
-            fonttype = 42
+            fonttype = 1
         else:
             font = self._get_font_ttf(prop)
             self.track_characters(font, s)
@@ -1627,9 +1627,9 @@
             font = self._get_font_afm(prop)
             l, b, w, h, d = font.get_str_bbox_and_descent(s)
             scale = prop.get_size_in_points()
-            w *= scale
-            h *= scale
-            d *= scale
+            w *= scale / 1000
+            h *= scale / 1000
+            d *= scale / 1000
         else:
             font = self._get_font_ttf(prop)
             font.set_text(s, 0.0, flags=LOAD_NO_HINTING)

Added: trunk/matplotlib/unit/test_pdf_use14corefonts.py
===================================================================
--- trunk/matplotlib/unit/test_pdf_use14corefonts.py                            
(rev 0)
+++ trunk/matplotlib/unit/test_pdf_use14corefonts.py    2009-02-10 22:16:35 UTC 
(rev 6904)
@@ -0,0 +1,25 @@
+# encoding: utf-8
+
+import matplotlib
+matplotlib.use('PDF')
+
+from matplotlib import rcParams
+import pylab
+
+rcParams['pdf.use14corefonts'] = True
+rcParams['font.family'] = 'sans-serif'
+rcParams['font.size'] = 8
+rcParams['font.sans-serif'] = ['Helvetica']
+
+title = u'Test PDF backend with option use14corefonts=True'
+
+text = u'''A three-line text positioned just above a blue line
+and containing some French characters and the euro symbol:
+"Merci pépé pour les 10 €"'''
+
+pylab.figure(figsize=(6, 4))
+pylab.title(title)
+pylab.text(0.5, 0.5, text, horizontalalignment='center')
+pylab.axhline(0.5, linewidth=0.5)
+pylab.savefig('test_pdf_use14corefonts.pdf')
+pylab.close()


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

------------------------------------------------------------------------------
Create and Deploy Rich Internet Apps outside the browser with Adobe(R)AIR(TM)
software. With Adobe AIR, Ajax developers can use existing skills and code to
build responsive, highly engaging applications that combine the power of local
resources and data with the reach of the web. Download the Adobe AIR SDK and
Ajax docs to start building applications today-http://p.sf.net/sfu/adobe-com
_______________________________________________
Matplotlib-checkins mailing list
Matplotlib-checkins@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins

Reply via email to