[reportlab-users] Verdana and TTF error

Robin Becker reportlab-users@reportlab.com
Fri, 07 May 2004 10:48:48 +0100


Ulrich Wisser wrote:

......
> 
> How should I procede to get the <b> markup working?
> 
> Thanks
> 
> Ulrich
......

The stuff in reportlab/lib/fonts.py is exactly that which is needed to do the 
transitions.

So in the _tt2ps map we need something like

('verdana', 0, 0) :'Verdana',
('verdana', 1, 0) :'Verdana-Bold',
('verdana', 0, 1) :'Verdana-Oblique',
('verdana', 1, 1) :'Verdana-BoldOblique',


so we need to register the verdana fonts with the right names

pdfmetrics.registerFont(TTFont('Verdana', 'VERDANA.TTF'))
pdfmetrics.registerFont(TTFont('Verdana-Bold', 'VERDANAB.TTF'))
pdfmetrics.registerFont(TTFont('Verdana-Italic', 'VERDANAI.TTF'))
pdfmetrics.registerFont(TTFont('Verdana-BoldItalic', 'VERDANAZ.TTF'))

then use addmapping from reportlab.lib.fonts

addMapping('verdana',0,0,'Verdana')
addMapping('verdana',1,0,'Verdana-Bold')
addMapping('verdana',0,1,'Verdana-Italic')
addMapping('verdana',1,1,'Verdana-BoldItalic')

This is probably not exactly right either as we attempt to calculate the inverse 
mappings from the same information.
-- 
Robin Becker