[reportlab-users] user manual updates
Brenda J. Butler
bjb at credil.org
Mon Mar 7 16:40:38 EST 2011
Two things: a documentation comment and a question.
** Documentation comment:
I'm trying out ReportLab, and I'm looking at the manual "ReportLab PDF
Library Users Guide" (ReportLab Version 2.5 Document generated on
2011/03/03 03:38:57).
My goal is that I want to embed some charts in a web page.
In chapter 2 (section 2.17) it mentions that charts are covered in a
separate document, "The ReportLab Graphics Library". I wonder if that
document has been merged into the document I'm reading as Chapter 11, or
if it is still a separate document? If separate, where can I get it?
** Question:
About the ArialMT font - I got the font zip file and unpacked it into
the reportlab font directory, but I still cannot use the Arial font.
More details:
The file I got was: http://www.reportlab.org/ftp/fonts/pfbfer.zip
I unpacked it into
/usr/local/pythonenv/CLIENTPORTAL/lib/python2.5/site-packages/reportlab/fonts.
I'm using a virtualenv for python, so
/usr/local/pythonenv/CLIENTPORTAL/lib/python2.5/site-packages is on the
python path (and the system site-packages is not).
The unpacked font files are readable by all.
I'm running this script:
#!/usr/bin/env python
import os
import reportlab
from reportlab.pdfgen import canvas
folder = os.path.dirname(reportlab.__file__) + os.sep + 'fonts'
afmFile = os.path.join(folder, 'DarkGardenMK.afm')
pfbFile = os.path.join(folder, 'DarkGardenMK.pfb')
from reportlab.pdfbase import pdfmetrics
justFace = pdfmetrics.EmbeddedType1Face(afmFile, pfbFile)
faceName = 'DarkGardenMK' # pulled from AFM file
pdfmetrics.registerTypeFace(justFace)
justFont = pdfmetrics.Font('DarkGardenMK',
faceName,
'WinAnsiEncoding')
pdfmetrics.registerFont(justFont)
c = canvas.Canvas ('foo.pdf')
c.setFont('DarkGardenMK', 32)
c.drawString(10, 150, 'This should be in')
c.drawString(10, 100, 'DarkGardenMK')
c.setFont('Courier-BoldOblique', 32)
c.drawString(10, 250, 'This should be in')
c.drawString(10, 200, 'Courier-BoldOblique')
c.setFont('Symbol', 18)
c.drawString(10, 350, 'This should be in')
c.drawString(10, 300, 'Symbol')
#c.setFont('ArialMT', 18)
#c.drawString(10, 350, 'This should be in')
#c.drawString(10, 300, 'ArialMT')
c.showPage ()
c.save ()
I have commented out the lines that gave me an error. The error was:
File
"/usr/local/pythonenv/CLIENTPORTAL/lib/python2.5/site-packages/reportlab/pdfbase/pdfmetrics.py",
line 638, in getTypeFace
return _typefaces[faceName]
KeyError: 'ArialMT'
(I ran the script under the virtualenv).
I saw the info about manually registering fonts using
pdfmetrics.EmbeddedType1Face
pdfmetrics.registerTypeFace
pdfmetrics.registerFont
But I don't have an afm file - just a pfb file.
Help?
Extra question:
Also, my system has the following directories with fonts in them, is it
ok to add a bunch of directories to the T1SearchPath like this:
T1SearchPath = (
# 'c:/Program Files/Adobe/Acrobat 9.0/Resource/Font',
# 'c:/Program Files/Adobe/Acrobat 8.0/Resource/Font',
# 'c:/Program Files/Adobe/Acrobat 7.0/Resource/Font',
# 'c:/Program Files/Adobe/Acrobat 6.0/Resource/Font',
#Win32, Acrobat 6
# 'c:/Program Files/Adobe/Acrobat 5.0/Resource/Font',
#Win32, Acrobat 5
# 'c:/Program Files/Adobe/Acrobat 4.0/Resource/Font',
#Win32, Acrobat 4
# '%(disk)s/Applications/Python
%(sys_version)s/reportlab/fonts', #Mac?
# '/usr/lib/Acrobat9/Resource/Font', #Linux, Acrobat 5?
# '/usr/lib/Acrobat8/Resource/Font', #Linux, Acrobat 5?
# '/usr/lib/Acrobat7/Resource/Font', #Linux, Acrobat 5?
# '/usr/lib/Acrobat6/Resource/Font', #Linux, Acrobat 5?
# '/usr/lib/Acrobat5/Resource/Font', #Linux, Acrobat 5?
# '/usr/lib/Acrobat4/Resource/Font', #Linux, Acrobat 4
# '/usr/local/Acrobat9/Resource/Font', #Linux, Acrobat 5?
# '/usr/local/Acrobat8/Resource/Font', #Linux, Acrobat 5?
# '/usr/local/Acrobat7/Resource/Font', #Linux, Acrobat 5?
# '/usr/local/Acrobat6/Resource/Font', #Linux, Acrobat 5?
# '/usr/local/Acrobat5/Resource/Font', #Linux, Acrobat 5?
# '/usr/local/Acrobat4/Resource/Font', #Linux, Acrobat 4
'%(REPORTLAB_DIR)s/fonts', #special
'%(REPORTLAB_DIR)s/../fonts', #special
'%(REPORTLAB_DIR)s/../../fonts', #special
'%(HOME)s/fonts', #special
'/usr/share/fonts/X11/Type1',
'/usr/share/fonts/type1/gsfonts',
'/usr/share/fonts/type1/mathml',
'/usr/share/texmf/fonts/type1/fkr/tipa',
'/usr/share/texmf/fonts/type1/public/lm',
'/usr/share/texmf-texlive/fonts/type1/adobe/courier',
'/usr/share/texmf-texlive/fonts/type1/adobe/utopia',
'/usr/share/texmf-texlive/fonts/type1/bitstrea/charter',
'/usr/share/texmf-texlive/fonts/type1/hoekwater/manfnt',
'/usr/share/texmf-texlive/fonts/type1/hoekwater/mflogo',
'/usr/share/texmf-texlive/fonts/type1/public/amsfonts/cm',
'/usr/share/texmf-texlive/fonts/type1/public/amsfonts/cmextra',
'/usr/share/texmf-texlive/fonts/type1/public/amsfonts/cyrillic',
'/usr/share/texmf-texlive/fonts/type1/public/amsfonts/euler',
'/usr/share/texmf-texlive/fonts/type1/public/amsfonts/latxfont',
'/usr/share/texmf-texlive/fonts/type1/public/amsfonts/symbols',
'/usr/share/texmf-texlive/fonts/type1/public/cbcoptic',
'/usr/share/texmf-texlive/fonts/type1/public/epiolmec',
'/usr/share/texmf-texlive/fonts/type1/public/esint-type1',
'/usr/share/texmf-texlive/fonts/type1/public/eurosym',
'/usr/share/texmf-texlive/fonts/type1/public/fpl',
'/usr/share/texmf-texlive/fonts/type1/public/marvosym',
'/usr/share/texmf-texlive/fonts/type1/public/mathpazo',
'/usr/share/texmf-texlive/fonts/type1/public/pxfonts',
'/usr/share/texmf-texlive/fonts/type1/public/rsfs',
'/usr/share/texmf-texlive/fonts/type1/public/txfonts',
'/usr/share/texmf-texlive/fonts/type1/public/wasy',
'/usr/share/texmf-texlive/fonts/type1/public/xypic',
'/usr/share/texmf-texlive/fonts/type1/urw/avantgar',
'/usr/share/texmf-texlive/fonts/type1/urw/bookman',
'/usr/share/texmf-texlive/fonts/type1/urw/courier',
'/usr/share/texmf-texlive/fonts/type1/urw/helvetic',
'/usr/share/texmf-texlive/fonts/type1/urw/ncntrsbk',
'/usr/share/texmf-texlive/fonts/type1/urw/palatino',
'/usr/share/texmf-texlive/fonts/type1/urw/symbol',
'/usr/share/texmf-texlive/fonts/type1/urw/times',
'/usr/share/texmf-texlive/fonts/type1/urw/zapfchan'
)
Is there a better way for a Debian squeeze system? I do understand that
I need to run that manual font registration for whatever fonts I want to
use.
Thanks for whatever help you can send,
--
}{ Centre for Research and Experimental Development in Informatics Libre
Brenda J. Butler
bjb at credil.org
+1 613 693 0684 #3202
F3018 - 283 Alexandre Taché
Gatineau (QC) J9A 1L8 CANADA
Sustainable Innovation // Innovation Durable
More information about the reportlab-users
mailing list