[reportlab-users] registering fonts

Carl Karsten carl at personnelware.com
Thu Jan 1 20:47:48 EST 2009

Roberto Alsina wrote:

> Carl Karsten writes:


>> 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?


> There is generic font embedding stuff in rst2pdf

> (http://rst2pdf.googlecode.com), where it will try to find a font by

> name using a variety of mechanisms.


> Can't give you more details right now because I'm at the beach but look

> for font stuff it should be easy to find :-)


if not f:
if f:
print f
if not f:


Any objections to this code being rolled into Reportlab?

Reportlab, any objections to this code being used in
reportlab/pdfbase/pdfmetrics.py? (guessing the MIT thing may require
something... no clue.)

Carl K

More information about the reportlab-users mailing list