[reportlab-users] fonts.py & RegisterFonts

Ian Sparks reportlab-users@reportlab.com
Thu, 29 May 2003 16:35:23 -0400


As Marc Stober identified in a recent post you can't register some fonts =
with registerFont() because fonts.py identifies a whole set of =
font-names that are supposedly "registered" which in fact are not part =
of the standard PDF set.

At the end of this message is the guilty dictionary in fonts.py which is =
the reason Marc can't register his 'verdana' font and I can't register =
an 'Arial' font. For now I'm working round it by registering my font as =
'XArial' (yuk).

Still, there must be a reason for this stuff in here...

- Ian Sparks.

_family_alias =3D {
            'serif':'times',
            'sansserif':'helvetica',
            'monospaced':'courier',
            'arial':'helvetica'
            }
#maps a piddle font to a postscript one.
_tt2ps_map =3D {
            #face, bold, italic -> ps name
            ('times', 0, 0) :'Times-Roman',
            ('times', 1, 0) :'Times-Bold',
            ('times', 0, 1) :'Times-Italic',
            ('times', 1, 1) :'Times-BoldItalic',

            ('courier', 0, 0) :'Courier',
            ('courier', 1, 0) :'Courier-Bold',
            ('courier', 0, 1) :'Courier-Oblique',
            ('courier', 1, 1) :'Courier-BoldOblique',

            ('helvetica', 0, 0) :'Helvetica',
            ('helvetica', 1, 0) :'Helvetica-Bold',
            ('helvetica', 0, 1) :'Helvetica-Oblique',
            ('helvetica', 1, 1) :'Helvetica-BoldOblique',
 =20
            # TTF fonts
            ('timesnew', 0, 0) :'Times New Roman',
            ('timesnew', 1, 0) :'Times New Roman-Bold',
            ('timesnew', 0, 1) :'Times New Roman-Italic',
            ('timesnew', 1, 1) :'Times New Roman-BoldItalic',
=20
            ('courier new', 0, 0) :'Courier New',
            ('courier new', 1, 0) :'Courier New-Bold',
            ('courier new', 0, 1) :'Courier New-Italic',
            ('courier new', 1, 1) :'Courier New-BoldItalic',

            ('verdana', 0, 0) :'Verdana',
            ('verdana', 1, 0) :'Verdana-Bold',
            ('verdana', 0, 1) :'Verdana-Italic',
            ('verdana', 1, 1) :'Verdana-BoldItalic',
=20
            ('arial', 0, 0) :'Arial',
            ('arial', 1, 0) :'Arial-Bold',
            ('arial', 0, 1) :'Arial-Italic',
            ('arial', 1, 1) :'Arial-BoldItalic',
=20
            ('arialnarrow', 0, 0) :'Arial Narrow',
            ('arialnarrow', 1, 0) :'Arial Narrow-Bold',
            ('arialnarrow', 0, 1) :'Arial Narrow-Italic',
            ('arialnarrow', 1, 1) :'Arial Narrow-BoldItalic',
=20
            ('bookmanos', 0, 0) :'Bookman Old Style',
            ('bookmanos', 1, 0) :'Bookman Old Style-Bold',
            ('bookmanos', 0, 1) :'Bookman Old Style-Italic',
            ('bookmanos', 1, 1) :'Bookman Old Style-BoldItalic',
=20
            ('georgia', 0, 0) :'Georgia',
            ('georgia', 1, 0) :'Georgia-Bold',
            ('georgia', 0, 1) :'Georgia-Italic',
            ('georgia', 1, 1) :'Georgia-BoldItalic',
=20
            ('trebuchet', 0, 0) :'Trebuchet MS',
            ('trebuchet', 1, 0) :'Trebuchet MS-Bold',
            ('trebuchet', 0, 1) :'Trebuchet MS-Italic',
            ('trebuchet', 1, 1) :'Trebuchet MS-BoldItalic',

            # there is only one Symbol font
            ('symbol', 0, 0) :'Symbol',
            ('symbol', 1, 0) :'Symbol',
            ('symbol', 0, 1) :'Symbol',
            ('symbol', 1, 1) :'Symbol',

            # ditto for dingbats
            ('zapfdingbats', 0, 0) :'ZapfDingbats',
            ('zapfdingbats', 1, 0) :'ZapfDingbats',
            ('zapfdingbats', 0, 1) :'ZapfDingbats',
            ('zapfdingbats', 1, 1) :'ZapfDingbats',
            }