Start at Reiner's answer.
It is perfect with one caveat.
Reportlab only searches for fonts in predefined folders:
TTFSearchPath = (
'c:/winnt/fonts',
'c:/windows/fonts',
'/usr/lib/X11/fonts/TrueType/',
'/usr/share/fonts/truetype',
'/usr/share/fonts', #Linux, Fedora
'/usr/share/fonts/dejavu', #Linux, Fedora
'%(REPORTLAB_DIR)s/fonts', #special
'%(REPORTLAB_DIR)s/../fonts', #special
'%(REPORTLAB_DIR)s/../../fonts',#special
'%(CWD)s/fonts', #special
'~/fonts',
'~/.fonts',
'%(XDG_DATA_HOME)s/fonts',
'~/.local/share/fonts',
#mac os X - from
#http://developer.apple.com/technotes/tn/tn2024.html
'~/Library/Fonts',
'/Library/Fonts',
'/Network/Library/Fonts',
'/System/Library/Fonts',
)
If you're trying to use a ttf font that you've downloaded off of the internet, and would like that font available on all your servers, I would suggest the following:
- Add the font to your project in any directory. e.g.: /project_root/app/lib/reportlabs/fonts/
Make sure you have something like BASE_DIR/ROOT_DIR in your settings:
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
add the following line to a python file that generates pdf:
import reportlab
from django.conf import settings
reportlab.rl_config.TTFSearchPath.append(str(settings.BASE_DIR) + '/app/lib/reportlabs/fonts')
pdfmetrics.registerFont(TTFont('Copperplate', 'Copperplate-Gothic-Bold.ttf'))