Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vertical alignment of ttf draw.text() plus fallback alpha 255 where only rgb specified #331

Merged
merged 2 commits into from
Sep 24, 2013

Conversation

paddywwoof
Copy link
Contributor

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;
NB I didn't make this change as I am not sure of the circumstances... maybe someone else can think about this and possibly tidy it up in future.

@aclark4life aclark4life merged commit 02855a8 into python-pillow:master Sep 24, 2013
radarhere pushed a commit to radarhere/Pillow that referenced this pull request Sep 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants