python-imaging/Pillow — pull request #331 by paddywwoof (2013-09-22 11:08:34+00:00)
Title: vertical alignment of ttf draw.text() plus fallback alpha 255 where only rgb specified

the vertical offset value in _imagingft.c font_getsize() was hard coded to 0 however the functionality existed for the image area to be offset by this amount to allow text to be drawn with baselines aligned to the correct value.

font_getsize() returns a tuple ((w, h), (xoffset, yoffset)) so ImageFont line 186 needed a [0] on the end

added a method getoffset() which would need to go in the documentation. (Using docstrings in the code and sphinx would make this much easier)

the existing mechanism in _imagingft.c font_render(), I'm not sure of the circumstances that PIXEL(glyph->metrics.horiBearingY) != glyph->bitmap_top but it seemed to work fine commenting out all the calculation of 'ascender' (surely descender more appropriate) and substituting
int yy = y + im->ysize - (PIXEL(glyph->metrics.horiBearingY) + ascender);
with
int yy = y + im->ysize - glyph->metrics.bitmap.rows;