[reportlab-users] registerFont(font) does addMapping in RL 1.17

Robin Becker reportlab-users@reportlab.com
Wed, 2 Apr 2003 16:43:09 +0100


In article <0f4001c2f923$62d8c460$03000000@over>, Ury Marshak <urym@two-
bytes.com> writes
>Hi,
>After some time I've decided to upgrade the RTL-languages support
>to version 1.17 . It went very smooth, but I've bumped into some other
>problem. Earlier I was using the following code to load TrueType font:
>
>def _load_times():
>    pdfmetrics.registerFont(TTFont('TimesNewRoman', 'times.ttf'))
>    pdfmetrics.registerFont(TTFont('TimesNewRomanBD', 'timesbd.ttf'))
>    pdfmetrics.registerFont(TTFont('TimesNewRomanI', 'timesi.ttf'))
>    pdfmetrics.registerFont(TTFont('TimesNewRomanBI', 'timesbi.ttf'))
>    addMapping('TimesNewRoman', 0, 0, 'TimesNewRoman') #normal
>    addMapping('TimesNewRoman', 1, 0, 'TimesNewRomanBD') #bold
>    addMapping('TimesNewRoman', 0, 1, 'TimesNewRomanI') #italic
>    addMapping('TimesNewRoman', 1, 1, 'TimesNewRomanBI') #bold italic
>
>
>But in 1.17 this code started throwing the exception, that looks like (this
>one
>speaks about Tahoma, but TimesNewRoman gives the same error):
>
>ValueError: _tt2ps_map[('tahoma', 1, 0)]==Tahoma already, not TahomaBD
>
>I tracked this down to a change in pdfbase/pdfmetrics.py ,
>registerFont(font) ,
>where the mappings are added automatically to be the same font. So this
>brings
>the following question - what is the recommended method now to do what I
>was doing before - loading different bold/italic fonts and setting the
>mapping?
>
I'm fairly sure that this attempt at mapping stuff is a bit broken. I
think someone started doing the _tt2ps mpping stuff inside registerFont
so that is the problem. I think there's a workaround by deleting the
existing entries and then doing the addMapping as above.
>Thanks,
>Ury
>
>
>P.S. Oh, one more thing... Is it possible to do underlined text?
.....

I think underlining works in one version of paragraphs (ie Aaron's new
para) and not in the other default one.
-- 
Robin Becker