add doctemplate support for intialFontName/Size/Leading, version --> 3.2.1
authorrobin
Fri, 19 Jun 2015 14:09:51 +0100
changeset 4211 464df39467fc
parent 4210 f3372610da00
child 4212 c903815560d1
add doctemplate support for intialFontName/Size/Leading, version --> 3.2.1
src/reportlab/__init__.py
src/reportlab/platypus/doctemplate.py
tests/test_invariant.py
--- a/src/reportlab/__init__.py	Fri Jun 19 12:22:17 2015 +0100
+++ b/src/reportlab/__init__.py	Fri Jun 19 14:09:51 2015 +0100
@@ -1,7 +1,7 @@
 #Copyright ReportLab Europe Ltd. 2000-2015
 #see license.txt for license details
 __doc__="""The Reportlab PDF generation library."""
-Version = "3.2.0"
+Version = "3.2.1"
 __version__=Version
 
 import sys, os, imp
--- a/src/reportlab/platypus/doctemplate.py	Fri Jun 19 12:22:17 2015 +0100
+++ b/src/reportlab/platypus/doctemplate.py	Fri Jun 19 14:09:51 2015 +0100
@@ -453,6 +453,9 @@
                     'enforceColorSpace': None,
                     'displayDocTitle': None,
                     'lang': None,
+                    'initialFontName': None,
+                    'initialFontSize': None,
+                    'initialLeading': None,
                     }
     _invalidInitArgs = ()
     _firstPageTemplateIndex = 0
@@ -857,6 +860,9 @@
                                 invariant=self.invariant,
                                 pageCompression=self.pageCompression,
                                 enforceColorSpace=self.enforceColorSpace,
+                                initialFontName = self.initialFontName,
+                                initialFontSize = self.initialFontSize,
+                                initialLeading = self.initialLeading,
                                 )
 
         getattr(self.canv,'setEncrypt',lambda x: None)(self.encrypt)
--- a/tests/test_invariant.py	Fri Jun 19 12:22:17 2015 +0100
+++ b/tests/test_invariant.py	Fri Jun 19 14:09:51 2015 +0100
@@ -14,7 +14,7 @@
 
 class InvarTestCase(unittest.TestCase):
     "Simplest test that makes PDF"
-    def test(self):
+    def test0(self):
         import os
         from reportlab.lib.testutils import testsFolder
         c = Canvas(filename, invariant=1, pageCompression=0)
@@ -24,7 +24,8 @@
         c.drawImage(gif,100,600)
         c.save()
 
-        raw1 = open(filename, 'rb').read()
+        with open(filename, 'rb') as f:
+            raw1 = f.read()
 
         c = Canvas(filename, invariant=1, pageCompression=0)
         c.setFont('Helvetica-Bold', 36)
@@ -32,9 +33,22 @@
         c.drawImage(gif,100,600)
         c.save()
 
-        raw2 = open(filename, 'rb').read()
+        with open(filename, 'rb') as f:
+            raw2 = f.read()
+
         assert raw1 == raw2, 'repeated runs differ!'
 
+    def test1(self):
+        import os
+        from reportlab.lib.testutils import testsFolder
+        filename = outputfile('test_no_helvetica.pdf')
+        c = Canvas(filename, invariant=1, pageCompression=0, initialFontName='Times-Roman')
+        c.drawString(100,700, 'Hello World')
+        c.save()
+        with open(filename, 'rb') as f:
+            raw = f.read()
+        assert b'Helvetica' not in raw and b'Times-Roman' in raw, 'Canvas initialFontName expectations not satisfied!'
+
 def makeSuite():
     return makeSuiteForClasses(InvarTestCase)