Conversation
|
I looked at this a bit and was confused by how characters are measured. Is this use of getbbox equivalent to how getsize was used before, e.g. does it handle the height of descenders (as in ‘q’ or ‘g’) the same way? If so LGTM. |
|
TBH I just looked at https://pillow.readthedocs.io/en/stable/_modules/PIL/ImageFont.html#ImageFont.getsize which shows that all of the three methods (getsize, getbbox, getlength) use the same underlying API... |
| return self.fonts['NORMAL'].getsize(text) | ||
| font = self.fonts['NORMAL'] | ||
| if hasattr(font, 'getbbox'): # Pillow >= 9.2.0 | ||
| return font.getbbox(text)[2:4] |
There was a problem hiding this comment.
| return font.getbbox(text)[2:4] | |
| return font.getlength(text) |
There was a problem hiding this comment.
If I read the docs correctly, getlength only returns a single value, while getsize returns (width, height).
Anteru
left a comment
There was a problem hiding this comment.
What was the reason to pick getbox over getlength? The underlying API is the same and this avoids unpacking the tuple.
No description provided.