Skip to content

Conversation

@mironleon
Copy link
Contributor

@jeanas
Copy link
Contributor

jeanas commented Jan 13, 2024

Thanks for the patch! Do you know if there is any functional difference between .textsize() and .textlength(), or is this just a renaming?

@jeanas
Copy link
Contributor

jeanas commented Jan 13, 2024

Also, .textlength() seems to have been added in version 9.2.0 which is from July 2022 according to https://pypi.org/project/pillow/#history. Maybe we still want to call .textsize() for older Pillow versions...

@mironleon
Copy link
Contributor Author

Thanks for the patch! Do you know if there is any functional difference between .textsize() and .textlength(), or is this just a renaming?

Should be exactly the same:
image

Call the deprecated method `textsize` when using older pillow versions
@mironleon
Copy link
Contributor Author

Also, .textlength() seems to have been added in version 9.2.0 which is from July 2022 according to https://pypi.org/project/pillow/#history. Maybe we still want to call .textsize() for older Pillow versions...

Good catch, I added a version check in fac8b0e

@mironleon
Copy link
Contributor Author

Let me know if you need anything else from my side!

@sagittarian
Copy link
Contributor

sagittarian commented Jan 19, 2024

I don't think this will work. .textsize returned a pair of (length, height), while textlength returns only the length. I was able to fix it for myself using font.getbbox(value) (ignoring the first two elements, which are always 0).

@jeanas
Copy link
Contributor

jeanas commented Jan 27, 2024

This looks good now. I've tested it with Pillow 10 and Pillow 9.5.0 (the latter was painful to build...). Thanks!

@jeanas jeanas merged commit 7b8928f into pygments:master Jan 27, 2024
@Anteru Anteru added this to the 2.18.0 milestone Apr 28, 2024
@Anteru Anteru added the A-formatting area: changes to formatters label Apr 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-formatting area: changes to formatters

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants