[reportlab-users] Some of the ttf font can't be registered

Tony Gu digisatori at gmail.com
Wed Sep 16 21:18:07 EDT 2009


Robin Becker 写道:

> Tony Gu wrote:

>> Hi,

>> I'm trying to register ttf font as stated below. It does work for many

>> fonts that I tested, but for certain fonts, it just throw AttributeError

>> as below:

>>

>> pdfmetrics.registerFont(TTFont('hei', 'Heiti.ttf'))

>>

>> in extractInfo

>> psName = names[6].replace(" ", "-") #Dinu Gherman's fix for font names

>> with spaces

>> AttributeError: 'NoneType' object has no attribute 'replace'

>>

>> Also, I tested on reportlab.lib.fontfinder module, it will return empty

>> list when I do the search in the folder where those above mentioned

>> 'Problematic' fonts located.

>>

>> so far the 'Problematic' fonts that I tested on are all Chinese fonts,

>> and probably they contain Chinese type face name. Will this be the

>> source of the problem? Is there anyway I can workaround this problem?

>>

>> Thanks and best regards,

>>

>> Tony Gu

> ........

>

> that sounds like it might be right. Can you send me one of the fonts

> that fails then I can look at exactly what the problem is.

>

> I suppose that the names[6] is being determined as None which implies

> that the postscript name is unset or in some unknown character set.

>

> Dinu's fix is actually hiding the true error I think as it comes

> immediately before

>

> if not psName:

> raise TTFError, "Could not find PostScript font name"

>

> which would get done if psName is None.

> --

> Robin Becker

> _______________________________________________

> reportlab-users mailing list

> reportlab-users at reportlab.com

> http://two.pairlist.net/mailman/listinfo/reportlab-users

Hi Robin,

Thank you very much for your prompt response, the attached is a font in
question.

Best regards,

Tony Gu
-------------- next part --------------
A non-text attachment was scrubbed...
Name: HYZhongHei.tar.gz
Type: application/x-gzip
Size: 2946413 bytes
Desc: not available
Url : <http://two.pairlist.net/pipermail/reportlab-users/attachments/20090917/46f1eb67/attachment-0001.bin>


More information about the reportlab-users mailing list