[reportlab-users] Getting rid of "Helvetica"

Robin Becker reportlab-users@reportlab.com
Tue, 10 Aug 2004 12:24:01 +0100


Michael Geddert wrote:

> Robin Becker wrote:
> 
>>>
>>> <*snip*>
>>>
>>
>> Are you referring to the standard font. That comes built in and costs 
>> little or nothing (there's a standard pdf fonts dictionary called 
>> 'BasicFonts'). So far as I know Helvetica is mentioned in canvas.py as 
>> an 'initial font'. I'm not the expert on that bit of code and Andy is 
>> away on holiday right now. If you preferred to set another standard 
>> font as 'initial' I'm sure that could be accomplished fairly easily.
>>
>> Can you explain why you want to remove Helvetica?
> 
> 
> Sure !
> 
> We are creating PDFs on the fly with Reportlab for a big customer project.
>  From time to time, our PDFs smash the printing machines in our customers
> prepress centre.
> We did some research and it all points down to the included-but-not-used
> "helvetica" Font. Anyway, the outages in our customer prepress centre is 
> *not*
> an issue with the toolkit, it is entirely due to their specific setup,we 
> just need a way to work around that.
> 
> BTW, our project doesn't involve a single standard font, all fonts are 
> special and "handmade" by our customer.
> 
> So, should I just empty the BasicFonts-Dictionary and Helvetica would be 
> gone ?
> That would be too easy, wouldn't it...
> 
> What would be the *best* way to go ?
>

I think the best way to go would be to change the code newar line 246 of 
canvas.py to alter the default font. So instead of

     iName = self._doc.getInternalFontName('Helvetica')

you need something like

     iName = self._doc.getInternalFontName('MyFont')

where you've previously declared MyFont as one of the fonts you want to use. 
However, I suspect you want to do this for a ttf font and that may not work as 
the internal stuff name seems to apply only to T1 fonts.

The code above is iused in creating the canvas._preamble which I suspect may not 
actually be required in all cases. For your purposes it may be sufficient to 
replace the whole of the _make_preamble method with

     def _make_preamble(self):
         self._preamble = ''

Can you try that out?
> Regards,
> Michael
> 
> 


-- 
Robin Becker