[reportlab-users] TrueType Fonts

Marek Pêtlicki reportlab-users@reportlab.com
Mon, 17 Mar 2003 13:42:58 +0100


Dnia 2003-03-13 19:28, Jarek Zgoda napisa³:
> Dnia Thu, Mar 13, 2003 at 05:27:37PM +0100, Marek Pêtlicki pisze:
> 
>>from reportlab.lib.fonts import addMapping
>>from reportlab.pdfbase import pdfmetrics
>>
>># Adding TT font Arial + mappings
>>pdfmetrics.registerFont(TTFont('Arial', 'arial.ttf'))
[...]
> Is there any reason, that you cann't register the font with some 
> other name?

no reason at all, but it is only 5% of the problem - still remains the 
problem with automatic addMapping (called by pdfmetrics.registerFont()). 
So after I do:

pdfmetrics.registerFont(TTFont('MyOwnArial', 'arial.ttf'))
pdfmetrics.registerFont(TTFont('MyOwnArial-Bold', 'arialb.ttf'))
pdfmetrics.registerFont(TTFont('MyOwnArial-BoldItalic', 'arialbi.ttf'))
pdfmetrics.registerFont(TTFont('MyOwnArial-Italic', 'ariali.ttf'))


I can't do:

addMapping('MyOwnArial', 0, 0, 'MyOwnArial')
addMapping('MyOwnArial', 1, 0, 'MyOwnArial-Bold')
addMapping('MyOwnArial', 0, 1, 'MyOwnArial-Italic')
addMapping('MyOwnArial', 1, 1, 'MyOwnArial-BoldItalic')

because it already has mappings defined (automatically, with only the 
first file: 'arial.ttf', so the whole virtual font doesn't contain 
versions for bold, italics and so on), and so it throws me a ValueError.


best

Marek Pêtlicki