Search code examples
pythongoogle-app-enginetruetypereportlab

Google App Engine, ReportLab and True Type Fonts


All! I'm writing an application that would run on Google App Engine. I'm using ReportLab for PDF files generation. However, the application needs to be able to generate PDF with cyrilic text. So I need to load some True Type Font. I should write something like this

pdfmetrics.registerFont(TTFont('Verdana', 'verdana.ttf'))

I tried to copy 'verdana.ttf' file to /reportlab/fonts but registerFont failed again. However in desktop environment it works fine.

How can I load True Type Font from application running on GAE?

Thanks in advance


Solution

  • According to the documentation:

    In Marius' original patch the filename was supposed to be exactly correct, but we have modified things so that if the filename is relative then a search for the corresponding file is done in the current directory and then in directories specified by reportlab.rl_config.TTFSearchpath!

    Since when you upload you won't be able to modify /reportlab/fonts, what you need to do is just upload it and then specify the location relative to the current working directory (should be the same directory as your Python code resides in, but if that doesn't work you might need to check the GAE documentation on where you can place support files like a font on the server).

    But maybe I misunderstand and that's what you tried to do and failed?