[reportlab-users] ValueError: Can't map determine family/bold/italic for sabon

Sebastian Ware sebastian at urbantalk.se
Fri Oct 1 04:45:24 EDT 2010


This is just a hint to save someone some trial and error. When mapping bold/italic etc. to a family it has to be a registered font

from reportlab.pdfbase import pdfmetrics
from reportlab.pdfbase.ttfonts import TTFont
pdfmetrics.registerFont(TTFont('SabonRom', 'SabonRom.ttf'))
pdfmetrics.registerFont(TTFont('SabonBol', 'SabonBol.ttf'))
pdfmetrics.registerFont(TTFont('SabonIta', 'SabonIta.ttf'))
pdfmetrics.registerFont(TTFont('SabonBolIta', 'SabonBolIta.ttf'))

# This DOES work:
from reportlab.lib.fonts import addMapping
addMapping('SabonRom', 0, 0, 'SabonRom') #normal
addMapping('SabonRom', 0, 1, 'SabonIta') #italic
addMapping('SabonRom', 1, 0, 'SabonBol') #bold
addMapping('SabonRom', 1, 1, 'SabonBolIta') #italic and bold
normal = ParagraphStyle(name='normal', fontName='SabonRom', fontSize=10, leading=1.4*10 )


# This DOES NOT work:
from reportlab.lib.fonts import addMapping
addMapping('Sabon', 0, 0, 'SabonRom') #normal
addMapping('Sabon', 0, 1, 'SabonIta') #italic
addMapping('Sabon', 1, 0, 'SabonBol') #bold
addMapping('Sabon', 1, 1, 'SabonBolIta') #italic and bold
normal = ParagraphStyle(name='normal', fontName='Sabon', fontSize=10, leading=1.4*10 )

Mvh Sebastian
0707- 577 858

http://www.urbantalk.se






More information about the reportlab-users mailing list