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

luma.emulator.device.asciiart: fix compatibility with Pillow ≥ 10 #68

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

markmentovai
Copy link

This accounts for two interface removals in Pillow 10:

Font size and offset methods. PIL.ImageFont.ImageFont.getsize was deprecated in Pillow 3c0b8763abb2 (9.2.0, 2022-07-01) and removed in Pillow b2301d70d104 (10.0.0, 2023-07-01). PIL.ImageFont.ImageFont.getbbox, available since Pillow c854bf8d1c05 (9.2.0, 2022-07-01), can be used as the basis for a replacement. Note that since Pillow 1e5aa21fa8ad (10.1.0, 2023-10-25), PIL.ImageFont.load_default may load a PIL.ImageFont.FreeTypeFont instead of PIL.ImageFont.ImageFont, but FreeTypeFont has supported getbbox for even longer, since Pillow 395aa946a9f1 (8.0.0, 2020-10-04).

Constants. PIL.Image.ANTIALIAS was deprecated in Pillow ed8073e846dd (9.1.0, 2022-04-01) and removed in Pillow c8ec15980b00 (10.0.0, 2023-07-01). PIL.Image.Resampling.LANCZOS, available since Pillow f8e4e9c2dd94 (9.1.0, 2022-04-01), is a direct replacement. This was previously addressed for luma.emulator.device.asciiblock in dae670a8e8a9, but luma.emulator.device.asciiart was not updated.

Because luma.emulator’s setup.cfg depends on luma.core >= 2.4.0, luma.core 2.4.0’s setup.cfg expresses its Pillow dependency as >= 9.2.0, and PIL.ImageFont.ImageFont.getbbox and PIL.Image.Resampling.LANCZOS are available in Pillow 9.2.0, there isn’t any need to make affordances for backwards compatibility with older Pillow versions.

This accounts for two interface removals in Pillow 10:

[Font size and offset
methods](https://pillow.readthedocs.io/en/stable/deprecations.html#font-size-and-offset-methods).
`PIL.ImageFont.ImageFont.getsize` was deprecated in [Pillow
3c0b8763abb2](python-pillow/Pillow@3c0b876)
(9.2.0, 2022-07-01) and removed in [Pillow
b2301d70d104](python-pillow/Pillow@b2301d7)
(10.0.0, 2023-07-01). `PIL.ImageFont.ImageFont.getbbox`, available since
[Pillow
c854bf8d1c05](python-pillow/Pillow@c854bf8)
(9.2.0, 2022-07-01), can be used as the basis for a replacement. Note
that since [Pillow
1e5aa21fa8ad](python-pillow/Pillow@1e5aa21)
(10.1.0, 2023-10-25), `PIL.ImageFont.load_default` may load a
`PIL.ImageFont.FreeTypeFont` instead of `PIL.ImageFont.ImageFont`, but
`FreeTypeFont` has supported `getbbox` for even longer, since [Pillow
395aa946a9f1](python-pillow/Pillow@395aa94)
(8.0.0, 2020-10-04).

[Constants](https://pillow.readthedocs.io/en/stable/deprecations.html#constants).
`PIL.Image.ANTIALIAS` was deprecated in [Pillow
ed8073e846dd](python-pillow/Pillow@ed8073e)
(9.1.0, 2022-04-01) and removed in [Pillow
c8ec15980b00](python-pillow/Pillow@c8ec159)
(10.0.0, 2023-07-01). `PIL.Image.Resampling.LANCZOS`, available since
[Pillow
f8e4e9c2dd94](python-pillow/Pillow@f8e4e9c)
(9.1.0, 2022-04-01), is a direct replacement. This was previously
addressed for `luma.emulator.device.asciiblock` in
[dae670a](rm-hull@dae670a),
but `luma.emulator.device.asciiart` was not updated.

Because [luma.emulator’s `setup.cfg` depends on luma.core `>=
2.4.0`](https://github.com/rm-hull/luma.emulator/blob/adc26e32cd718a732d8ae08c1720d696008161c2/setup.cfg#L35),
[luma.core 2.4.0’s `setup.cfg` expresses its Pillow dependency as `>=
9.2.0`](https://github.com/rm-hull/luma.core/blob/2.4.0/setup.cfg#L31),
and `PIL.ImageFont.ImageFont.getbbox` and `PIL.Image.Resampling.LANCZOS`
are available in Pillow 9.2.0, there isn’t any need to make affordances
for backwards compatibility with older Pillow versions.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant