reportlab: new base font mechanism more fully applied
authorrgbecker
Wed, 14 Apr 2010 17:13:41 +0000
changeset 3368 afa025c34493
parent 3367 bce0159f2980
child 3369 34942d4dbcfa
reportlab: new base font mechanism more fully applied
src/reportlab/graphics/charts/axes.py
src/reportlab/graphics/charts/legends.py
src/reportlab/graphics/charts/textlabels.py
src/reportlab/graphics/renderPDF.py
src/reportlab/graphics/renderbase.py
src/reportlab/graphics/shapes.py
src/reportlab/graphics/testshapes.py
src/reportlab/lib/fonts.py
src/reportlab/lib/styles.py
src/reportlab/pdfbase/ttfonts.py
src/reportlab/platypus/doctemplate.py
src/reportlab/platypus/figures.py
src/reportlab/platypus/flowables.py
src/reportlab/platypus/para.py
src/reportlab/platypus/paraparser.py
src/reportlab/platypus/tableofcontents.py
src/reportlab/platypus/tables.py
src/reportlab/rl_config.py
--- a/src/reportlab/graphics/charts/axes.py	Wed Apr 14 12:39:46 2010 +0000
+++ b/src/reportlab/graphics/charts/axes.py	Wed Apr 14 17:13:41 2010 +0000
@@ -1788,6 +1788,7 @@
 
 def sample1():
     "Sample drawing containing two unconnected axes."
+    from reportlab.graphics.shapes import _baseGFontNameB
     drawing = Drawing(400, 200)
     data = [(10, 20, 30, 42)]
     xAxis = XCategoryAxis()
@@ -1797,7 +1798,7 @@
     xAxis.labels.boxAnchor = 'n'
     xAxis.labels[3].dy = -15
     xAxis.labels[3].angle = 30
-    xAxis.labels[3].fontName = 'Times-Bold'
+    xAxis.labels[3].fontName = _baseGFontNameB
     yAxis = YValueAxis()
     yAxis.setPosition(50, 50, 125)
     yAxis.configure(data)
--- a/src/reportlab/graphics/charts/legends.py	Wed Apr 14 12:39:46 2010 +0000
+++ b/src/reportlab/graphics/charts/legends.py	Wed Apr 14 17:13:41 2010 +0000
@@ -18,6 +18,7 @@
 from reportlab.graphics.charts.areas import PlotArea
 from reportlab.graphics.widgets.markers import uSymbol2Symbol, isSymbol
 from reportlab.lib.utils import isSeqType, find_locals
+from reportlab.graphics.shapes import _baseGFontName
 
 def _transMax(n,A):
     X = n*[0]
@@ -524,7 +525,7 @@
         return d
 
 class TotalAnnotator(LegendColEndCallout):
-    def __init__(self, lText='Total', rText='0.0', fontName='Times-Roman', fontSize=10,
+    def __init__(self, lText='Total', rText='0.0', fontName=_baseGFontName, fontSize=10,
             fillColor=colors.black, strokeWidth=0.5, strokeColor=colors.black, strokeDashArray=None,
             dx=0, dy=0, dly=0, dlx=(0,0)):
         self.lText = lText
--- a/src/reportlab/graphics/charts/textlabels.py	Wed Apr 14 12:39:46 2010 +0000
+++ b/src/reportlab/graphics/charts/textlabels.py	Wed Apr 14 17:13:41 2010 +0000
@@ -13,6 +13,7 @@
 from reportlab.graphics.shapes import Drawing, Group, Circle, Rect, String, STATE_DEFAULTS
 from reportlab.graphics.shapes import _PATH_OP_ARG_COUNT, _PATH_OP_NAMES, definePath
 from reportlab.graphics.widgetbase import Widget, PropHolder
+from reportlab.graphics.shapes import _baseGFontName
 
 _gs = None
 _A2BA=  {
@@ -55,7 +56,7 @@
         P.extend(g[1:])
     return R
 
-def _text2PathDescription(text, x=0, y=0, fontName='Times-Roman', fontSize=1000,
+def _text2PathDescription(text, x=0, y=0, fontName=_baseGFontName, fontSize=1000,
                             anchor='start', truncate=1, pathReverse=0):
     global _gs
     if not _gs:
@@ -74,7 +75,7 @@
         P.extend(_processGlyph(g,truncate=truncate,pathReverse=pathReverse))
     return P
 
-def _text2Path(text, x=0, y=0, fontName='Times-Roman', fontSize=1000,
+def _text2Path(text, x=0, y=0, fontName=_baseGFontName, fontSize=1000,
                 anchor='start', truncate=1, pathReverse=0):
     return definePath(_text2PathDescription(text,x=x,y=y,fontName=fontName,
                     fontSize=fontSize,anchor=anchor,truncate=truncate,pathReverse=pathReverse))
--- a/src/reportlab/graphics/renderPDF.py	Wed Apr 14 12:39:46 2010 +0000
+++ b/src/reportlab/graphics/renderPDF.py	Wed Apr 14 17:13:41 2010 +0000
@@ -306,8 +306,9 @@
 #
 #########################################################
 def test():
+    from reportlab.graphics.shapes import _baseGFontName, _baseGFontNameBI
     c = Canvas('renderPDF.pdf')
-    c.setFont('Times-Roman', 36)
+    c.setFont(_baseGFontName, 36)
     c.drawString(80, 750, 'Graphics Test')
 
     # print all drawings and their doc strings from the test
@@ -323,7 +324,7 @@
             drawings.append((drawing, docstring))
 
     #print in a loop, with their doc strings
-    c.setFont('Times-Roman', 12)
+    c.setFont(_baseGFontName, 12)
     y = 740
     i = 1
     for (drawing, docstring) in drawings:
@@ -333,9 +334,9 @@
             y = 740
         # draw a title
         y = y - 30
-        c.setFont('Times-BoldItalic',12)
+        c.setFont(_baseGFontNameBI,12)
         c.drawString(80, y, 'Drawing %d' % i)
-        c.setFont('Times-Roman',12)
+        c.setFont(_baseGFontName,12)
         y = y - 14
         textObj = c.beginText(80, y)
         textObj.textLines(docstring)
--- a/src/reportlab/graphics/renderbase.py	Wed Apr 14 12:39:46 2010 +0000
+++ b/src/reportlab/graphics/renderbase.py	Wed Apr 14 17:13:41 2010 +0000
@@ -127,9 +127,10 @@
 def testStateTracker():
     print 'Testing state tracker'
     defaults = {'fillColor':None, 'strokeColor':None,'fontName':None, 'transform':[1,0,0,1,0,0]}
+    from reportlab.graphics.shapes import _baseGFontName
     deltas = [
         {'fillColor':'red'},
-        {'fillColor':'green', 'strokeColor':'blue','fontName':'Times-Roman'},
+        {'fillColor':'green', 'strokeColor':'blue','fontName':_baseGFontName},
         {'transform':[0.5,0,0,0.5,0,0]},
         {'transform':[0.5,0,0,0.5,2,3]},
         {'strokeColor':'red'}
--- a/src/reportlab/graphics/shapes.py	Wed Apr 14 12:39:46 2010 +0000
+++ b/src/reportlab/graphics/shapes.py	Wed Apr 14 17:13:41 2010 +0000
@@ -11,7 +11,7 @@
 from pprint import pprint
 
 from reportlab.platypus import Flowable
-from reportlab.rl_config import shapeChecking, verbose, defaultGraphicsFontName, _unset_
+from reportlab.rl_config import shapeChecking, verbose, defaultGraphicsFontName as _baseGFontName, _unset_
 from reportlab.lib import logger
 from reportlab.lib import colors
 from reportlab.lib.validators import *
@@ -19,6 +19,10 @@
 from reportlab.lib.attrmap import *
 from reportlab.lib.utils import fp_str
 from reportlab.pdfbase.pdfmetrics import stringWidth
+from reportlab.lib.fonts import tt2ps
+_baseGFontNameB = tt2ps(_baseGFontName,1,0)
+_baseGFontNameI = tt2ps(_baseGFontName,0,1)
+_baseGFontNameBI = tt2ps(_baseGFontName,1,1)
 
 class NotImplementedError(Exception):
     pass
@@ -53,7 +57,7 @@
     #'fillRule': NON_ZERO_WINDING, - these can be done later
 
     'fontSize': 10,
-    'fontName': defaultGraphicsFontName,
+    'fontName': _baseGFontName,
     'textAnchor':  'start' # can be start, middle, end, inherited
     }
 
--- a/src/reportlab/graphics/testshapes.py	Wed Apr 14 12:39:46 2010 +0000
+++ b/src/reportlab/graphics/testshapes.py	Wed Apr 14 17:13:41 2010 +0000
@@ -26,15 +26,47 @@
 from reportlab.graphics.renderPDF import _PDFRenderer
 import unittest
 
-_FONTS = ['Times-Roman','Courier','Times-BoldItalic',]
+_FONTS = ['Times-Roman','Vera','Times-BoldItalic',]
+
+def _setup():
+    from reportlab.pdfbase import pdfmetrics, ttfonts
+    pdfmetrics.registerFont(ttfonts.TTFont("Vera", "Vera.ttf"))
+    pdfmetrics.registerFont(ttfonts.TTFont("VeraBd", "VeraBd.ttf"))
+    pdfmetrics.registerFont(ttfonts.TTFont("VeraIt", "VeraIt.ttf"))
+    pdfmetrics.registerFont(ttfonts.TTFont("VeraBI", "VeraBI.ttf"))
+    F = ['Times-Roman','Courier','Helvetica','Vera', 'VeraBd', 'VeraIt', 'VeraBI']
+    if sys.platform=='win32':
+        for name, ttf in [
+            ('Adventurer Light SF','Advlit.ttf'),('ArialMS','ARIAL.TTF'),
+            ('Arial Unicode MS', 'ARIALUNI.TTF'),
+            ('Book Antiqua','BKANT.TTF'),
+            ('Century Gothic','GOTHIC.TTF'),
+            ('Comic Sans MS', 'COMIC.TTF'),
+            ('Elementary Heavy SF Bold','Vwagh.ttf'),
+            ('Firenze SF','flot.ttf'),
+            ('Garamond','GARA.TTF'),
+            ('Jagger','Rols.ttf'),
+            ('Monotype Corsiva','MTCORSVA.TTF'),
+            ('Seabird SF','seag.ttf'),
+            ('Tahoma','TAHOMA.TTF'),
+            ('VerdanaMS','VERDANA.TTF'),
+            ]:
+            for D in ('c:\WINNT','c:\Windows'):
+                fn = os.path.join(D,'Fonts',ttf)
+                if os.path.isfile(fn):
+                    try:
+                        f = ttfonts.TTFont(name, fn)
+                        pdfmetrics.registerFont(f)
+                        F.append(name)
+                    except:
+                        pass
+_setup()
 
 #########################################################
 #
 #   Collections of shape drawings.
 #
 #########################################################
-
-
 def getFailedDrawing(funcName):
     """Generate a drawing in case something goes really wrong.
 
@@ -391,39 +423,6 @@
 
 def getDrawing13():
     'Test Various TTF Fonts'
-    from reportlab.pdfbase import pdfmetrics, ttfonts
-    pdfmetrics.registerFont(ttfonts.TTFont("Vera", "Vera.ttf"))
-    pdfmetrics.registerFont(ttfonts.TTFont("VeraBd", "VeraBd.ttf"))
-    pdfmetrics.registerFont(ttfonts.TTFont("VeraIt", "VeraIt.ttf"))
-    pdfmetrics.registerFont(ttfonts.TTFont("VeraBI", "VeraBI.ttf"))
-    _FONTS[1]='Vera'
-    _FONTS[1]='VeraBI'
-    F = ['Times-Roman','Courier','Helvetica','Vera', 'VeraBd', 'VeraIt', 'VeraBI']
-    if sys.platform=='win32':
-        for name, ttf in [
-            ('Adventurer Light SF','Advlit.ttf'),('ArialMS','ARIAL.TTF'),
-            ('Arial Unicode MS', 'ARIALUNI.TTF'),
-            ('Book Antiqua','BKANT.TTF'),
-            ('Century Gothic','GOTHIC.TTF'),
-            ('Comic Sans MS', 'COMIC.TTF'),
-            ('Elementary Heavy SF Bold','Vwagh.ttf'),
-            ('Firenze SF','flot.ttf'),
-            ('Garamond','GARA.TTF'),
-            ('Jagger','Rols.ttf'),
-            ('Monotype Corsiva','MTCORSVA.TTF'),
-            ('Seabird SF','seag.ttf'),
-            ('Tahoma','TAHOMA.TTF'),
-            ('VerdanaMS','VERDANA.TTF'),
-            ]:
-            for D in ('c:\WINNT','c:\Windows'):
-                fn = os.path.join(D,'Fonts',ttf)
-                if os.path.isfile(fn):
-                    try:
-                        f = ttfonts.TTFont(name, fn)
-                        pdfmetrics.registerFont(f)
-                        F.append(name)
-                    except:
-                        pass
 
     def drawit(F,w=400,h=200,fontSize=12,slack=2,gap=5):
         D = Drawing(w,h)
--- a/src/reportlab/lib/fonts.py	Wed Apr 14 12:39:46 2010 +0000
+++ b/src/reportlab/lib/fonts.py	Wed Apr 14 17:13:41 2010 +0000
@@ -49,7 +49,6 @@
             ('helvetica', 0, 1) :'Helvetica-Oblique',
             ('helvetica', 1, 1) :'Helvetica-BoldOblique',
 
-
             # there is only one Symbol font
             ('symbol', 0, 0) :'Symbol',
             ('symbol', 1, 0) :'Symbol',
@@ -61,8 +60,6 @@
             ('zapfdingbats', 1, 0) :'ZapfDingbats',
             ('zapfdingbats', 0, 1) :'ZapfDingbats',
             ('zapfdingbats', 1, 1) :'ZapfDingbats',
-
-
             }
 
 _ps2tt_map={}
@@ -75,7 +72,7 @@
     psfn = psfn.lower()
     if psfn in _ps2tt_map:
         return _ps2tt_map[psfn]
-    raise ValueError, "Can't map determine family/bold/italic for %s" % psfn
+    raise ValueError("Can't map determine family/bold/italic for %s" % psfn)
 
 def tt2ps(fn,b,i):
     'family name + bold & italic to ps font name'
@@ -87,7 +84,7 @@
         K = fn, b1|b, i1|i
         if K in _tt2ps_map:
             return _tt2ps_map[K]
-    raise ValueError, "Can't find concrete font for family=%s, bold=%d, italic=%d" % (fn, b, i)
+    raise ValueError("Can't find concrete font for family=%s, bold=%d, italic=%d" % (fn, b, i))
 
 def addMapping(face, bold, italic, psname):
     'allow a custom font to be put in the mapping'
--- a/src/reportlab/lib/styles.py	Wed Apr 14 12:39:46 2010 +0000
+++ b/src/reportlab/lib/styles.py	Wed Apr 14 17:13:41 2010 +0000
@@ -4,7 +4,6 @@
 __version__=''' $Id$ '''
 __doc__='''Classes for ParagraphStyle and similar things.
 
-
 A style is a collection of attributes, but with some extra features
 to allow 'inheritance' from a parent, and to ensure nobody makes
 changes after construction.
@@ -15,8 +14,20 @@
 getSampleStyleSheet()  returns a stylesheet you can use for initial
 development, with a few basic heading and text styles.
 '''
+__all__=(
+        'PropertySet',
+        'ParagraphStyle',
+        'LineStyle',
+        'StyleSheet1',
+        'getSampleStyleSheet',
+        )
 from reportlab.lib.colors import white, black
 from reportlab.lib.enums import TA_LEFT, TA_CENTER
+from reportlab.lib.fonts import tt2ps
+from reportlab.rl_config import canvas_basefontname as _baseFontName
+_baseFontNameB = tt2ps(_baseFontName,1,0)
+_baseFontNameI = tt2ps(_baseFontName,0,1)
+_baseFontNameBI = tt2ps(_baseFontName,1,1)
 
 ###########################################################
 # This class provides an 'instance inheritance'
@@ -51,7 +62,6 @@
         for (key, value) in kw.items():
              self.__dict__[key] = value
 
-
     def __repr__(self):
         return "<%s '%s'>" % (self.__class__.__name__, self.name)
 
@@ -64,7 +74,6 @@
                 if (key not in ['name','parent']):
                     self.__dict__[key] = value
 
-
     def listAttrs(self, indent=''):
         print indent + 'name =', self.name
         print indent + 'parent =', self.parent
@@ -78,7 +87,7 @@
 
 class ParagraphStyle(PropertySet):
     defaults = {
-        'fontName':'Times-Roman',
+        'fontName':_baseFontName,
         'fontSize':10,
         'leading':12,
         'leftIndent':0,
@@ -87,7 +96,7 @@
         'alignment':TA_LEFT,
         'spaceBefore':0,
         'spaceAfter':0,
-        'bulletFontName':'Times-Roman',
+        'bulletFontName':_baseFontName,
         'bulletFontSize':10,
         'bulletIndent':0,
         'textColor': black,
@@ -138,7 +147,6 @@
         self.byName = {}
         self.byAlias = {}
 
-
     def __getitem__(self, key):
         try:
             return self.byAlias[key]
@@ -146,7 +154,7 @@
             try:
                 return self.byName[key]
             except KeyError:
-                raise KeyError, "Style '%s' not found in stylesheet" % key
+                raise KeyError("Style '%s' not found in stylesheet" % key)
 
     def __contains__(self, key):
         return key in self.byAlias or key in self.byName
@@ -154,15 +162,15 @@
     def add(self, style, alias=None):
         key = style.name
         if key in self.byName:
-            raise KeyError, "Style '%s' already defined in stylesheet" % key
+            raise KeyError("Style '%s' already defined in stylesheet" % key)
         if key in self.byAlias:
-            raise KeyError, "Style name '%s' is already an alias in stylesheet" % key
+            raise KeyError("Style name '%s' is already an alias in stylesheet" % key)
 
         if alias:
             if alias in self.byName:
-                raise KeyError, "Style '%s' already defined in stylesheet" % alias
+                raise KeyError("Style '%s' already defined in stylesheet" % alias)
             if alias in self.byAlias:
-                raise KeyError, "Alias name '%s' is already an alias in stylesheet" % alias
+                raise KeyError("Alias name '%s' is already an alias in stylesheet" % alias)
         #passed all tests?  OK, add it
         self.byName[key] = style
         if alias:
@@ -180,12 +188,9 @@
             style.listAttrs('    ')
             print
 
-
-
-
 def testStyles():
     pNormal = ParagraphStyle('Normal',None)
-    pNormal.fontName = 'Times-Roman'
+    pNormal.fontName = _baseFontName
     pNormal.fontSize = 12
     pNormal.leading = 14.4
 
@@ -201,7 +206,7 @@
     stylesheet = StyleSheet1()
 
     stylesheet.add(ParagraphStyle(name='Normal',
-                                  fontName='Times-Roman',
+                                  fontName=_baseFontName,
                                   fontSize=10,
                                   leading=12)
                    )
@@ -212,12 +217,12 @@
                    )
     stylesheet.add(ParagraphStyle(name='Italic',
                                   parent=stylesheet['BodyText'],
-                                  fontName = 'Times-Italic')
+                                  fontName = _baseFontNameI)
                    )
 
     stylesheet.add(ParagraphStyle(name='Heading1',
                                   parent=stylesheet['Normal'],
-                                  fontName = 'Times-Bold',
+                                  fontName = _baseFontNameB,
                                   fontSize=18,
                                   leading=22,
                                   spaceAfter=6),
@@ -225,7 +230,7 @@
 
     stylesheet.add(ParagraphStyle(name='Title',
                                   parent=stylesheet['Normal'],
-                                  fontName = 'Times-Bold',
+                                  fontName = _baseFontNameB,
                                   fontSize=18,
                                   leading=22,
                                   alignment=TA_CENTER,
@@ -234,7 +239,7 @@
 
     stylesheet.add(ParagraphStyle(name='Heading2',
                                   parent=stylesheet['Normal'],
-                                  fontName = 'Times-Bold',
+                                  fontName = _baseFontNameB,
                                   fontSize=14,
                                   leading=18,
                                   spaceBefore=12,
@@ -243,7 +248,7 @@
 
     stylesheet.add(ParagraphStyle(name='Heading3',
                                   parent=stylesheet['Normal'],
-                                  fontName = 'Times-BoldItalic',
+                                  fontName = _baseFontNameBI,
                                   fontSize=12,
                                   leading=14,
                                   spaceBefore=12,
@@ -252,7 +257,7 @@
 
     stylesheet.add(ParagraphStyle(name='Heading4',
                                   parent=stylesheet['Normal'],
-                                  fontName = 'Times-BoldItalic',
+                                  fontName = _baseFontNameBI,
                                   fontSize=10,
                                   leading=12,
                                   spaceBefore=10,
@@ -261,7 +266,7 @@
 
     stylesheet.add(ParagraphStyle(name='Heading5',
                                   parent=stylesheet['Normal'],
-                                  fontName = 'Times-Bold',
+                                  fontName = _baseFontNameB,
                                   fontSize=9,
                                   leading=10.8,
                                   spaceBefore=8,
@@ -270,7 +275,7 @@
 
     stylesheet.add(ParagraphStyle(name='Heading6',
                                   parent=stylesheet['Normal'],
-                                  fontName = 'Times-Bold',
+                                  fontName = _baseFontNameB,
                                   fontSize=7,
                                   leading=8.4,
                                   spaceBefore=6,
@@ -289,7 +294,7 @@
                                   leftIndent=36,
                                   bulletIndent=0,
                                   spaceBefore=6,
-                                  bulletFontName='Times-BoldItalic'),
+                                  bulletFontName=_baseFontNameBI),
                    alias='df')
 
     stylesheet.add(ParagraphStyle(name='Code',
@@ -300,5 +305,4 @@
                                   firstLineIndent=0,
                                   leftIndent=36))
 
-
     return stylesheet
--- a/src/reportlab/pdfbase/ttfonts.py	Wed Apr 14 12:39:46 2010 +0000
+++ b/src/reportlab/pdfbase/ttfonts.py	Wed Apr 14 17:13:41 2010 +0000
@@ -999,7 +999,7 @@
     _multiByte = 1      # We want our own stringwidth
     _dynamicFont = 1    # We want dynamic subsetting
 
-    def __init__(self, name, filename, validate=0, subfontIndex=0,asciiReadable=1):
+    def __init__(self, name, filename, validate=0, subfontIndex=0,asciiReadable=None):
         """Loads a TrueType font from filename.
 
         If validate is set to a false values, skips checksum validation.  This
@@ -1010,6 +1010,8 @@
         self.encoding = TTEncoding()
         from weakref import WeakKeyDictionary
         self.state = WeakKeyDictionary()
+        if asciiReadable is None:
+            asciiReadable = rl_config.ttfAsciiReadable
         self._asciiReadable = asciiReadable
 
     def _py_stringWidth(self, text, size, encoding='utf-8'):
--- a/src/reportlab/platypus/doctemplate.py	Wed Apr 14 12:39:46 2010 +0000
+++ b/src/reportlab/platypus/doctemplate.py	Wed Apr 14 17:13:41 2010 +0000
@@ -1144,7 +1144,7 @@
     print 'PROGRESS MONITOR:  %-10s   %d' % (typ, value)
 
 if __name__ == '__main__':
-
+    from reportlab.lib.styles import _baseFontName, _baseFontNameB
     def myFirstPage(canvas, doc):
         from reportlab.lib.colors import red
         PAGE_HEIGHT = canvas._pagesize[1]
@@ -1152,9 +1152,9 @@
         canvas.setStrokeColor(red)
         canvas.setLineWidth(5)
         canvas.line(66,72,66,PAGE_HEIGHT-72)
-        canvas.setFont('Times-Bold',24)
+        canvas.setFont(_baseFontNameB,24)
         canvas.drawString(108, PAGE_HEIGHT-108, "TABLE OF CONTENTS DEMO")
-        canvas.setFont('Times-Roman',12)
+        canvas.setFont(_baseFontName,12)
         canvas.drawString(4 * inch, 0.75 * inch, "First Page")
         canvas.restoreState()
 
@@ -1165,7 +1165,7 @@
         canvas.setStrokeColor(red)
         canvas.setLineWidth(5)
         canvas.line(66,72,66,PAGE_HEIGHT-72)
-        canvas.setFont('Times-Roman',12)
+        canvas.setFont(_baseFontName,12)
         canvas.drawString(4 * inch, 0.75 * inch, "Page %d" % doc.page)
         canvas.restoreState()
 
--- a/src/reportlab/platypus/figures.py	Wed Apr 14 12:39:46 2010 +0000
+++ b/src/reportlab/platypus/figures.py	Wed Apr 14 17:13:41 2010 +0000
@@ -17,12 +17,13 @@
 from reportlab.lib.enums import TA_LEFT, TA_RIGHT, TA_CENTER
 from reportlab.lib.validators import isColor
 from reportlab.lib.colors import toColor
+from reportlab.lib.styles import _baseFontName, _baseFontNameI
 
-captionStyle = ParagraphStyle('Caption', fontName='Times-Italic', fontSize=10, alignment=TA_CENTER)
+captionStyle = ParagraphStyle('Caption', fontName=_baseFontNameI, fontSize=10, alignment=TA_CENTER)
 
 class Figure(Flowable):
     def __init__(self, width, height, caption="",
-                 captionFont="Times-Italic", captionSize=12,
+                 captionFont=_baseFontNameI, captionSize=12,
                  background=None,
                  captionTextColor=toColor('black'),
                  captionBackColor=None,
@@ -46,7 +47,6 @@
         self.border = border
         self.spaceBefore = spaceBefore
         self.spaceAfter = spaceAfter
-
         self._getCaptionPara()  #Larry Meyn's fix - otherwise they all get the number of the last chapter.
 
     def _getCaptionPara(self):
@@ -247,7 +247,6 @@
         self.canv.scale(self._scaleFactor, self._scaleFactor)
         self.drawing.drawOn(self.canv, 0, 0)
 
-
 try:
     from rlextra.pageCatcher.pageCatcher import restoreForms, storeForms, storeFormsInMemory, restoreFormsInMemory
     _hasPageCatcher = 1
@@ -269,7 +268,6 @@
             root, ext = os.path.splitext(filename)
             return '%s_page%d' % (root, pageNo)
 
-
         def needsProcessing(self, pdfFileName, pageNo):
             "returns 1 if no forms or form is older"
             formName = self.getFormName(pdfFileName, pageNo)
@@ -365,7 +363,7 @@
                     5*inch,     # height
                     showBoundary = 1  # helps us see what's going on
                     )
-    bodyStyle = ParagraphStyle('Body', fontName='Times-Roman', fontSize=24, leading=28, spaceBefore=6)
+    bodyStyle = ParagraphStyle('Body', fontName=_baseFontName, fontSize=24, leading=28, spaceBefore=6)
     para1 = Paragraph('Spam spam spam spam. ' * 5, bodyStyle)
     para2 = Paragraph('Eggs eggs eggs. ' * 5, bodyStyle)
     mydata = [para1, para2]
--- a/src/reportlab/platypus/flowables.py	Wed Apr 14 12:39:46 2010 +0000
+++ b/src/reportlab/platypus/flowables.py	Wed Apr 14 17:13:41 2010 +0000
@@ -29,6 +29,7 @@
 from reportlab.lib.colors import red, gray, lightgrey
 from reportlab.lib.utils import fp_str
 from reportlab.lib.enums import TA_LEFT, TA_CENTER, TA_RIGHT, TA_JUSTIFY
+from reportlab.lib.styles import _baseFontName
 from reportlab.pdfbase import pdfutils
 from reportlab.rl_config import _FUZZ, overlapAttachedSpace, ignoreContainerActions
 
@@ -210,7 +211,7 @@
         self.canv.line(0, self.height, self.width, 0)
 
         #centre the text
-        self.canv.setFont('Times-Roman',12)
+        self.canv.setFont(_baseFontName,12)
         self.canv.drawCentredString(0.5*self.width, 0.5*self.height, self.text)
 
 def _trimEmptyLines(lines):
--- a/src/reportlab/platypus/para.py	Wed Apr 14 12:39:46 2010 +0000
+++ b/src/reportlab/platypus/para.py	Wed Apr 14 17:13:41 2010 +0000
@@ -58,13 +58,12 @@
   (define document destination inside paragraph, color is optional)</setLink>
 
 """
-
 from reportlab.pdfbase.pdfmetrics import stringWidth
 from reportlab.lib.utils import fp_str
 from reportlab.platypus.flowables import Flowable
 from reportlab.lib import colors
-
 from types import StringType, UnicodeType, InstanceType, TupleType, ListType, FloatType
+from reportlab.lib.styles import _baseFontName
 
 # SET THIS TO CAUSE A VIEWING BUG WITH ACROREAD 3 (for at least one input)
 # CAUSEERROR = 0
@@ -971,7 +970,7 @@
 class SimpleStyle:
     "simplified paragraph style without all the fancy stuff"
     name = "basic"
-    fontName='Times-Roman'
+    fontName=_baseFontName
     fontSize=10
     leading=12
     leftIndent=0
@@ -980,7 +979,7 @@
     alignment=TA_LEFT
     spaceBefore=0
     spaceAfter=0
-    bulletFontName='Times-Roman'
+    bulletFontName=_baseFontName
     bulletFontSize=10
     bulletIndent=0
     textColor=black
@@ -2304,7 +2303,7 @@
                     ('rightIndent', 200),
                     ('bullet', 'very long bullet', 50, 'Courier', 14),
                     ('align', TA_CENTER),
-                    ('face', "Times-Roman"),
+                    ('face', _baseFontName),
                     ('size', 12),
                     ('leading', 14),
                     ] + splitspace("This is the first segment of the first paragraph.") + [
@@ -2314,7 +2313,7 @@
                     ('nextLine', 0),
                     ('align', TA_LEFT),
                     ('bullet', 'Bullet', 10, 'Courier', 8),
-                    ('face', "Times-Roman"),
+                    ('face', _baseFontName),
                     ('size', 12),
                     ('leading', 14),
                     ] + splitspace("This is the SECOND!!! segment of the first paragraph. This is the first segment of the first paragraph. This is the first segment of the first paragraph. This is the first segment of the first paragraph. This is the first segment of the first paragraph. ") + [
--- a/src/reportlab/platypus/paraparser.py	Wed Apr 14 12:39:46 2010 +0000
+++ b/src/reportlab/platypus/paraparser.py	Wed Apr 14 17:13:41 2010 +0000
@@ -1094,6 +1094,7 @@
 
 if __name__=='__main__':
     from reportlab.platypus import cleanBlockQuotedText
+    from reportlab.lib.styles import _baseFontName
     _parser=ParaParser()
     def check_text(text,p=_parser):
         print '##########'
@@ -1111,11 +1112,11 @@
                 else: print
 
     style=ParaFrag()
-    style.fontName='Times-Roman'
+    style.fontName=_baseFontName
     style.fontSize = 12
     style.textColor = black
     style.bulletFontName = black
-    style.bulletFontName='Times-Roman'
+    style.bulletFontName=_baseFontName
     style.bulletFontSize=12
 
     text='''
@@ -1133,7 +1134,7 @@
     '''
     check_text(text)
     check_text('<para> </para>')
-    check_text('<para font="times-bold" size=24 leading=28.8 spaceAfter=72>ReportLab -- Reporting for the Internet Age</para>')
+    check_text('<para font="%s" size=24 leading=28.8 spaceAfter=72>ReportLab -- Reporting for the Internet Age</para>'%_baseFontName)
     check_text('''
     <font color=red>&tau;</font>Tell me, O muse, of that ingenious hero who travelled far and wide
     after he had sacked the famous town of Troy. Many cities did he visit,
--- a/src/reportlab/platypus/tableofcontents.py	Wed Apr 14 12:39:46 2010 +0000
+++ b/src/reportlab/platypus/tableofcontents.py	Wed Apr 14 17:13:41 2010 +0000
@@ -47,7 +47,7 @@
 from reportlab.lib import enums
 from reportlab.lib.units import cm
 from reportlab.lib.utils import commasplit, escapeOnce
-from reportlab.lib.styles import ParagraphStyle
+from reportlab.lib.styles import ParagraphStyle, _baseFontName
 from reportlab.platypus.paragraph import Paragraph
 from reportlab.platypus.doctemplate import IndexingFlowable
 from reportlab.platypus.tables import TableStyle, Table
@@ -140,7 +140,7 @@
 defaultLevelStyles = [
     ParagraphStyle(
         name='Level 0',
-        fontName='Times-Roman',
+        fontName=_baseFontName,
         fontSize=10,
         leading=11,
         firstLineIndent = 0,
@@ -339,7 +339,7 @@
         
         if style is None:
             style = ParagraphStyle(name='index',
-                                        fontName='Times-Roman',
+                                        fontName=_baseFontName,
                                         fontSize=11)
         self.textStyle = style
         self.tableStyle = tableStyle or defaultTableStyle
--- a/src/reportlab/platypus/tables.py	Wed Apr 14 12:39:46 2010 +0000
+++ b/src/reportlab/platypus/tables.py	Wed Apr 14 17:13:41 2010 +0000
@@ -19,14 +19,14 @@
 """
 from reportlab.platypus.flowables import Flowable, Preformatted
 from reportlab import rl_config
-from reportlab.lib.styles import PropertySet, ParagraphStyle
+from reportlab.lib.styles import PropertySet, ParagraphStyle, _baseFontName
 from reportlab.lib import colors
 from reportlab.lib.utils import fp_str
 from reportlab.pdfbase.pdfmetrics import stringWidth
 
 class CellStyle(PropertySet):
     defaults = {
-        'fontname':'Times-Roman',
+        'fontname':_baseFontName,
         'fontsize':10,
         'leading':12,
         'leftPadding':6,
@@ -47,7 +47,7 @@
 
 # experimental replacement
 class CellStyle1(PropertySet):
-    fontname = "Times-Roman"
+    fontname = _baseFontName
     fontsize = 10
     leading = 12
     leftPadding = 6
--- a/src/reportlab/rl_config.py	Wed Apr 14 12:39:46 2010 +0000
+++ b/src/reportlab/rl_config.py	Wed Apr 14 17:13:41 2010 +0000
@@ -7,7 +7,7 @@
 allowTableBoundsErrors =    1 # set to 0 to die on too large elements in tables in debug (recommend 1 for production use)
 shapeChecking =             1
 defaultEncoding =           'WinAnsiEncoding'       # 'WinAnsi' or 'MacRoman'
-defaultGraphicsFontName=    'Times-Roman'               #initializer for STATE_DEFAULTS in shapes.py
+defaultGraphicsFontName=    'Times-Roman'           #initializer for STATE_DEFAULTS in shapes.py
 pageCompression =           1                       # default page compression mode
 useA85 =                    1                       #set to 0 to disable Ascii Base 85 stream filters
 defaultPageSize =           'A4'                    #default page size