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

Describe difference between font size and bbox #7806

Merged
merged 8 commits into from
Mar 11, 2024

Conversation

radarhere
Copy link
Member

@radarhere radarhere commented Feb 17, 2024

Resolves #7802

The user in the issue thinks that the documentation could use further detail about the transition from font.getsize() to font.getbbox().

I've amended the deprecations and release notes documentation with the following

Previously, the size methods returned a height that included the vertical offset of the text, while the new bbox methods explicitly distinguish this as a top offset.

While here, I also noticed that some of the example code didn't use the font declared earlier, so I've fixed that.

Copy link

@stweil stweil left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's better, thank you!

offset.

.. image:: ./example/size_vs_bbox.png
:alt: Demonstration of size height vs bbox top and bottom
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather than saying what the image is, could you describe what the image conveys?

Imagine it read aloud to you when you can't see the image.

https://accessibility.huit.harvard.edu/describe-content-images

Copy link
Member Author

@radarhere radarhere Feb 20, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've pushed a commit.

In bbox methods, top measures the vertical distance above the text, while bottom measures that plus the vertical distance of the text itself. In size methods, height also measures the vertical distance above the text plus the vertical distance of the text itself.

I don't really like it, but it was a struggle to explain the meaning of 'height', 'top' and 'bottom' without using those words in the definitions of those terms themselves.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! It can be a challenge to write good alt text.

I read it through and understood the difference without looking at the image. 👍

Copy link
Contributor

@nulano nulano left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've created radarhere#23 to also show how anchors can be used to align text, which I have seen to be a common source of confusion with this change.

I originally wanted to write this back when these functions were being deprecated, but I didn't have time to get to it then and forgot to get back to it until now.

docs/releasenotes/9.2.0.rst Outdated Show resolved Hide resolved
radarhere and others added 3 commits February 20, 2024 21:37
Co-authored-by: Ondrej Baranovič <nulano@nulano.eu>
Show how to use anchors to align text in ImageFont deprecations
@hugovk hugovk merged commit 350d7f2 into python-pillow:main Mar 11, 2024
7 of 8 checks passed
@radarhere radarhere deleted the imagefont branch March 12, 2024 00:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Misleading deprecations documentation for getsize
4 participants