[reportlab-users] Bug when importing TrueType fonts with names containing blanks

Dinu Gherman gherman at darwin.in-berlin.de
Thu Nov 29 15:16:08 EST 2007


Robin Becker:


> Tim Roberts wrote:

>> Dinu Gherman wrote:

>>> Hi,

>>>

>>> I'm getting an error when trying to use TrueType fonts containing

>>> blanks in their font names. See the following traceback:

>>>

>>> Traceback (most recent call last):

>>> ...

>>> reportlab.pdfbase.ttfonts.TTFError: psName='UniversalCondensed

>>> Regular' contains invalid character ' ' ie U+0020

>>>

>>> I can workaround this with the following simple minded patch to

>>> reportlab/pdfbase/ttfonts.py, but I'm not sure if this is a proper

>>> solution:

>> No, it's not, because it's not necessary. Remember that the font

>> name

>> you pass to TTFont does not have to be related to the actual font

>> name

>> in any way. It is just an alias that you use to refer to the font in

>> future canvas.setFont commands. If you want to think of it as "UCR",

>> you can do that. If you want to use the hyphenated name, then pass

>> UniversalCondensed-Regular to TTFont. It's up to you.


It' not about the font name I choose, it's about the font name found
during parsing the TTF file.


> I think we can replace the space with a suitable character, but are we

> entitled to?


Anything that works is ok. If PS names don't like blanks it's the PS
specification that gives you permission to work around it.

Dinu



More information about the reportlab-users mailing list