Join GitHub today
Fixed bugs in calculating text size #3864
With English characters, each subsequent character ends horizontally after all of the previous ones. Pillow has a variable
From the issue, there are two characters - the backwards S at the bottom, and the line at the top. The backwards S ends horizontally after the line at the top - the horizontal clipping occurs because Pillow stops the size after the line at the top. So instead, check each character to see if it has the maximum x value.
The first diagram at https://www.freetype.org/freetype2/docs/tutorial/step2.html is helpful in understanding the glyph properties.
With regards to changing the vertical clipping, I presume that Pillow is not correctly processing the fact that the line at the top does not start at the baseline - there is a gap. Flipping the signs when applying the offset fixes this problem, with the only affect on existing tests being that a text string is moved vertically up.
Let me know if anything is still unclear.