[reportlab-users] registering fonts

Carl Karsten carl at personnelware.com
Thu Jan 1 19:59:11 EST 2009


I am finding myself trying to write generic code to register fonts.

Looking at reportlab/pdfbase/pdfmetrics.py I see much the same code, but it
depends on external stuff (system wide config files, editing
/usr/lib/python2.5/site-packages/reportlab/rl_config.py, and maybe setting an
environment var, but I couldn't get that to work.)

Or maybe I am missing something.

Here is what I am hoping for: my app that uses reportlab these 2 fonts:

/usr/share/fonts/type1/gsfonts/n019004l.afm which is part of
http://packages.ubuntu.com/intrepid/all/gsfonts/filelist

/usr/share/fonts/truetype/freefont/FreeSans.ttf from
http://packages.ubuntu.com/intrepid/ttf-freefont

My app has a local config file that holds things like database/user/pw - great
place to store path's to fonts
either the font's and dirs and fonts used:

fonts=['NimbusSanL-Bold','FreeSans']
fontdirs=['/usr/share/fonts/type1/gsfonts/',
'/usr/share/fonts/truetype/freefont/']

or the full pathnames:

fontfiles=['/usr/share/fonts/type1/gsfonts/n019004l.afm',
'/usr/share/fonts/truetype/freefont/FreeSans.ttf']

Then my app can have some generic code that registers those fonts. I am
guessing most apps that use reportlab need this, so it would be great if I could
just pass those lists into some reporlab code.

So, does anything like this exist? If not, I'll be happy to code it up and
submit a patch - anything I should know?

Carl K








More information about the reportlab-users mailing list