-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
getsize_multiline doesn't take into account characters that extend below the baseline #5816
Comments
Of course, immediately after opening that issue, I find a very promising method: |
Both
It seems I didn't add a warning to the multiline version, likely because I didn't add a
In fact, I think this might not be entirely accurate due to the way Pillow computes line spacing - glancing at the source I suspect it is measuring to the bottom baseline instead in most cases and ignoring the last descender line like you mentioned. Instead, I believe
As for why Edit: For more information see #4959 and the linked issues. |
This deprecation sounds reasonable. What do others think? If adding warnings now (Pillow 9.0.0, 2022-01-02), it would be eligible for removal in Pillow 10.0.0 (2023-07-01), giving a nice long deprecation period. |
Yes indeed, thank you so much! I have one follow-up question: Thank you so much! |
I don't think that what you're describing should break in the future - and yes, it sounds like a reasonable way of doing things. |
If we deprecate those, we should also then add |
Probably. That is what I was unsure about and why I didn't propose deprecating earlier. I'll take a look at this as part of #6195 (comment). |
@nulano are you still working on a deprecation PR? I ask because we are approaching Pillow 9.2.0, the last chance to have a year of deprecation before Pillow 10.0.0. |
Yes, should be done some time this week. |
What did you do?
I'm using
getsize_multiline
to compute the size of a text label that I render to an image. The image is exactly the size of the text label.I noticed that my text labels where cropped; specifically, when there are letters like
p
org
(which extend below the baseline) on the last line of text, these letters get cropped.The problem doesn't affect
getsize
, and can easily be exhibited by comparing the sizes reported bygetsize
vsgetsize_multiline
for a single line string likeg
.Example:
What did you expect to happen?
The
getsize
andgetsize_multiline
methods should return the same size.What actually happened?
With
DroidSans
in size 20:getsize
returns (10,24)getsize_multiline
returns (10,19)The
g
actually extends below if I create a label of size 10,19 and draw the stringg
on it, theg
gets cropped.What are your OS, Python and Pillow versions?
getsize:
getsize_multiline:
I imagine that the logic in getsize_multiline doesn't take into accounts characters that extend below the baseline. For now I'm going to just add a bit of padding on the last line 😅 but I guess there has to be a better way.
The text was updated successfully, but these errors were encountered: