[Image-SIG] Re: rendering symbol font with pil 1.4
Fredrik Lundh
fredrik at pythonware.com
Sat Sep 27 08:24:47 EDT 2003
Angel Perea Martinez wrote:
> Hi, I´m relatively new to PIL, so perhaps I`m
> overseeing something trivial, but when I use the font
> Symbol with truetype (in the truetype mode, i see only
> squares. I have no problem with other types, as arial
> etc.
>
> f = ImageFont.truetype(n,fSize)
> self.draw.text ((x,y), text.encode("Latin-1"), font = f)
PIL's current freetype driver only supports fonts that use the Unicode
character set; Microsoft's Symbol font uses a proprietary encoding.
as a quick workaround, change the "getfont" method in _imagingft.c
so that the last few lines look like this:
if (error) {
PyObject_DEL(self);
PyErr_SetString(PyExc_IOError, "cannot load font");
return NULL;
}
/* --- start of patch --- */
/* explicitly select Unicode or Symbol charmap */
if (FT_Select_Charmap(self->face, ft_encoding_unicode))
FT_Select_Charmap(self->face, ft_encoding_symbol);
/* --- end of patch --- */
return (PyObject*) self;
also, the symbol characters lie in the 0xF000-0xF0FF character range;
to draw e.g. symbol 68 (whatever that is), pass in unichr(0xf000+68)
to the "text" method.
</F>
More information about the Image-SIG
mailing list