luma.emulator icon indicating copy to clipboard operation
luma.emulator copied to clipboard

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

Open markmentovai opened this issue 9 months ago • 0 comments

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.

markmentovai avatar Feb 05 '25 16:02 markmentovai