What fonts are available to use with PIL on App Engine?
I know I can upload a font as part of the application but what I basically want is a system provided sans-serif that will work with unicode characters that is a good looking Helvetica (or alternative). Google servers may already have some fonts installed and this is what I would like some insight into.
I would like to find a font to use that is unicode capable so Japanese and other characters will render properly using PIL.
I have a web page that renders unicode characters properly using font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
When I use PIL to render the same unicode characters they do not render properly. The font I uploaded as part of the app does not have the necessary unicode characters in the font.
Here are the relevant python lines of code from what I am using now.
import Image, ImageDraw, ImageFont
draw = ImageDraw.Draw(my_output)
font = ImageFont.truetype("FontIAmUsing.otf", font_size, encoding="utf-8")
draw.text((5, 51), 'abc', fill='#2A2A2A', font=font)
Considering that PIL only ships with a default bitmap font (ugly and probably not containing a very wide range of unicode characters) and since you have to provide the full path to your font file AND you cannot get outside of your sandboxed environment in GAE, you are better just uploading your fonts along with your application. If you don't specify a path, it will look at the root of your web application. I am using the GoogleAppEngineLauncher for OSX and when deploying it uploads all the files found (including the .ttf I am using with ImageDraw).
The documentation at http://effbot.org/imagingbook/imagefont.htm states: (New in 1.1.4) Load a "better than nothing" default font. I just confirmed that the default font is available on GAE.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With