[reportlab-users] TTFont in ParagraphStyle

Robin Becker reportlab-users@reportlab.com
Wed, 16 Oct 2002 15:12:01 +0100


In article <FDEJJKLBELAKNCMDIADEEEOBCCAA.Jo-Bader@gmx.de>, Jo-
Bader@gmx.de writes
>
>Hello,
>
>i try to get a custom TT-Font into a ParagraphStyle
>which is for formating a paragraph in a Table
>
>
>       pdfmetrics.registerFont(TTFont('Arial', 'Arialn.ttf')) # works fine
>
>       levelZeroParaStyle = \
>           ParagraphStyle(name='LevelZero',
>                          fontName='Arial',
>                          fontSize=10,
>                          leading=11,                     
>                          firstLineIndent = -epsilon,
>                          leftIndent = 0*delta + epsilon)
>
>       ...
......
I think there's a bug in what's currently being done for registration.
The problem is that when we use bold/italic etc we need to have the
concept of a root face name. That allows us to map

 -   -       b    -      -     i      b     i
Times-Roman Times-Bold Times-Italic Times-BoldItalic

I'm fairly sure that registerFont isn't doing the right thing about
this.

Assuming that Arial is the base font you need to do something like

        from reportlab.lib import fonts
        fonts._tt2ps_map.update({
                        ('arial', 0, 0) :'Arial',
                        ('arial', 1, 0) :'Arial',
                        ('arial', 0, 1) :'Arial',
                        ('arial', 1, 1) :'Arial',
                        })
        fonts._ps2tt_map.update({'arial': ('arial',0,0)})


of course to do it correctly you need to register the correct fonts and
use their names rather than just Arial.
-- 
Robin Becker