[reportlab-users] registering font does not work after switching media server

Andy Robinson andy at reportlab.com
Thu Mar 25 07:53:58 EDT 2010


On 25 March 2010 11:31, Thomas Kremmel <thomasspin at gmail.com> wrote:

> Tried it like this:

> pdfmetrics.registerFont(TTFont('Calibri',

> 'my_project/media/fonts/calibri.ttf'))

> or

>  pdfmetrics.registerFont(TTFont('Calibri-Bold',

> 'media/fonts/calibri-bold.ttf'))

> But anyway, thats more a server question, than a reportlab question ;-)


You need to provide an absolute path. Otherwise, it looks relative to
the 'current working directory'; if doing "manage.py runserver" that's
inside your project code, but inside Apache it could be '/' or
somewhere else unpredictable.

All our settings.py files tend to have a variable MEDIA_DIR set to the
disk location of the files, rather than the URL; we'd build the full
pathname to the fonts using this.

Hope this helps,

Andy


More information about the reportlab-users mailing list