platypus/para.py: fix up brokenness wrt utf8, unicode still waits
authorrgbecker
Mon, 03 Jul 2006 10:11:30 +0000
changeset 2655 c7333c9b3ed3
parent 2654 202c2b5e100e
child 2656 3e2a3ad2d595
platypus/para.py: fix up brokenness wrt utf8, unicode still waits
reportlab/platypus/para.py
--- a/reportlab/platypus/para.py	Fri Jun 30 09:15:09 2006 +0000
+++ b/reportlab/platypus/para.py	Mon Jul 03 10:11:30 2006 +0000
@@ -698,9 +698,7 @@
                     size = self.fontSize
                     textobject.setFont(font, size)
                 if topcode in (StringType, UnicodeType):
-                    #textobject.textOut(opcode)
-                    text = escape(opcode)
-                    code.append('(%s) Tj' % text)
+                    textobject.textOut(opcode)
                 else:
                     # drawable thing
                     opcode.execute(self, textobject, canvas)
@@ -1171,9 +1169,7 @@
                 else:
                     textobject.setWordSpace(0.0)
             textobject.setTextOrigin(x,y)
-            text = escape(text)
-            code.append('(%s) Tj' % text)
-            #textobject.textOut(text)
+            textobject.textOut(text)
             y = y-leading
         c.drawText(textobject)
 
@@ -1992,7 +1988,7 @@
     Controller["title"] = theParaMapper
 
 def handleSpecialCharacters(engine, text, program=None):
-    from paraparser import greeks, symenc
+    from paraparser import greeks
     from string import whitespace, atoi, atoi_error
     standard={'lt':'<', 'gt':'>', 'amp':'&'}
     # add space prefix if space here
@@ -2029,26 +2025,14 @@
                             n = atoi(name[1:])
                     except atoi_error:
                         n = -1
-                    if 0<=n<=255: fragment = chr(n)+fragment[semi+1:]
-                    elif symenc.has_key(n):
-                        fragment = fragment[semi+1:]
-                        (f,b,i) = engine.shiftfont(program, face="symbol")
-                        program.append(symenc[n])
-                        engine.shiftfont(program, face=f)
-                        if fragment and fragment[0] in whitespace:
-                            program.append(" ") # follow with a space
+                    if n>=0:
+                        fragment = unichr(n).encode('utf8')+fragment[semi+1:]
                     else:
                         fragment = "&"+fragment
                 elif standard.has_key(name):
                     fragment = standard[name]+fragment[semi+1:]
                 elif greeks.has_key(name):
-                    fragment = fragment[semi+1:]
-                    greeksub = greeks[name]
-                    (f,b,i) = engine.shiftfont(program, face="symbol")
-                    program.append(greeksub)
-                    engine.shiftfont(program, face=f)
-                    if fragment and fragment[0] in whitespace:
-                        program.append(" ") # follow with a space
+                    fragment = greeks[name]+fragment[semi+1:]
                 else:
                     # add back the &
                     fragment = "&"+fragment
@@ -2254,7 +2238,7 @@
 
 <para alignment="justify">
 <font color="red" size="15">R</font>ed letter. thisisareallylongword andsoisthis andthisislonger
-justified text paragraph example
+justified text paragraph example with a pound sign \xc2\xa3
 justified text paragraph example
 justified text paragraph example
 </para>