[reportlab-users] TableStyle "FONTNAME"
    Jason Craig 
    jason at iwocreative.com
       
    Thu Jan 17 14:19:17 EST 2008
    
    
  
Robin Becker wrote:
> shawn a wrote:
>> I have the following code
>>
>>     s.append(TableStyle([
>>     ('GRID',(0,1),(-1,-1),1,colors.black),
>>     ('FONTNAME',(0,0),(-1,-1),'Arial')
>>     ]))
>>
>> Im getting a key error
>>
>> ...........
>>     return findFontAndRegister(fontName)
>>   File "c:\python25\lib\site-packages\reportlab\pdfbase\pdfmetrics.py",
>> line 659, in findFontAndRegister
>>     face = getTypeFace(fontName)
>>   File "c:\python25\lib\site-packages\reportlab\pdfbase\pdfmetrics.py",
>> line 618, in getTypeFace
>>     return _typefaces[faceName]
>> KeyError: 'Arial'
>>
>> Is there a list of the fonts that reportlab registers for you along
>> with the string names?
>>
>> thanks,
>> -Shawn
> .......
> The standard 14 fonts are all listed in reportlab/pdfbase/_fontdata.py;
> standardFonts = (
>     'Courier', 'Courier-Bold', 'Courier-Oblique', 'Courier-BoldOblique',
>     'Helvetica', 'Helvetica-Bold', 'Helvetica-Oblique', 
> 'Helvetica-BoldOblique',
>     'Times-Roman', 'Times-Bold', 'Times-Italic', 'Times-BoldItalic',
>     'Symbol','ZapfDingbats')
>
> These are the fonts which are built in to Acrobat Reader. You can 
> register fonts like Arial using code like
>
> from reportlab.pdfbase import pdfmetrics, ttfonts
> pdfmetrics.registerFont(ttfonts.TTFont("Arial", "path_to_arial.ttf"))
Note that "Helvetica" is usually another name for "Arial".
--Jason
    
    
More information about the reportlab-users
mailing list