ReportLab newbie

D

Damjan

I'm trying this script with reportlab:

from reportlab.pdfbase import pdfmetrics
from reportlab.pdfbase.ttfonts import TTFont
fontname = 'Arial-Bold'
my_TTF = '/opt/Fonts/arial.ttf'
font = TTFont(fontname, my_TTF)
pdfmetrics.registerFont(font)

But the register complains with this exception:

ValueError: _tt2ps_map[('arial', 1, 0)]==Arial-Bold already, not Arial

what does it mean?
 
L

Lee Harr

I'm trying this script with reportlab:

from reportlab.pdfbase import pdfmetrics
from reportlab.pdfbase.ttfonts import TTFont
fontname = 'Arial-Bold'
my_TTF = '/opt/Fonts/arial.ttf'
font = TTFont(fontname, my_TTF)
pdfmetrics.registerFont(font)

But the register complains with this exception:

ValueError: _tt2ps_map[('arial', 1, 0)]==Arial-Bold already, not Arial

what does it mean?


Sorry, not sure, but reportlab has an active and quite
supportive mailing list if no one here has an answer:

http://www.reportlab.org/
http://two.pairlist.net/mailman/listinfo/reportlab-users
 
T

Tim Roberts

Damjan said:
I'm trying this script with reportlab:

from reportlab.pdfbase import pdfmetrics
from reportlab.pdfbase.ttfonts import TTFont
fontname = 'Arial-Bold'
my_TTF = '/opt/Fonts/arial.ttf'
font = TTFont(fontname, my_TTF)
pdfmetrics.registerFont(font)

Do you realize that arial.ttf is normal Arial, and not bold? Arial bold
lives in arialbd.ttf.

Reportlab automatically registers the Arial family. You shouldn't need to
register it yourself.
 
D

Damjan

from reportlab.pdfbase import pdfmetrics
Do you realize that arial.ttf is normal Arial, and not bold? Arial bold
lives in arialbd.ttf.

Ahh, stupid copy/paste...
the exception was raised when fontname = "Arial" ...
the above example doesn't raise an exception, and it was experiment.
Reportlab automatically registers the Arial family.  You shouldn't need to
register it yourself.

it seems that I can't register "Arial" as fontname since Reportlab does it
automatically... in the end, fontname = 'MyArial' did fine.
 
T

Tim Roberts

Damjan said:
it seems that I can't register "Arial" as fontname since Reportlab does it
automatically... in the end, fontname = 'MyArial' did fine.

Yes, but since ReportLab has already done this for you, why would you do it
yourself?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,209
Messages
2,571,089
Members
47,689
Latest member
kilaocrhtbfnr

Latest Threads

Top