summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWilliam Breathitt Gray <william.gray@linaro.org>2023-07-30 08:49:57 -0400
committerSam James <sam@gentoo.org>2023-08-03 23:11:26 +0100
commitdca26e82bc4e1c3d249911d50c0983e8b2175eed (patch)
treef0e83300f34462b9a5a189ba170a4fe1d5a4b254 /games-fps/freedm-data
parentgames-fps/freedoom-data: Support Python PIL 10.0.0 (diff)
downloadgentoo-dca26e82bc4e1c3d249911d50c0983e8b2175eed.tar.gz
gentoo-dca26e82bc4e1c3d249911d50c0983e8b2175eed.tar.bz2
gentoo-dca26e82bc4e1c3d249911d50c0983e8b2175eed.zip
games-fps/freedm-data: Support Python PIL 10.0.0
Closes: https://bugs.gentoo.org/909540 Signed-off-by: William Breathit Gray <william.gray@linaro.org> Closes: https://github.com/gentoo/gentoo/pull/32104 Signed-off-by: Sam James <sam@gentoo.org>
Diffstat (limited to 'games-fps/freedm-data')
-rw-r--r--games-fps/freedm-data/files/freedm-data-0.12.1-Python-PIL-10.0.0-support.patch39
-rw-r--r--games-fps/freedm-data/freedm-data-0.12.1-r1.ebuild4
2 files changed, 43 insertions, 0 deletions
diff --git a/games-fps/freedm-data/files/freedm-data-0.12.1-Python-PIL-10.0.0-support.patch b/games-fps/freedm-data/files/freedm-data-0.12.1-Python-PIL-10.0.0-support.patch
new file mode 100644
index 000000000000..130e1636374d
--- /dev/null
+++ b/games-fps/freedm-data/files/freedm-data-0.12.1-Python-PIL-10.0.0-support.patch
@@ -0,0 +1,39 @@
+From d64ddc6ea90406e21b4b93f5a1e7f99abfaac0d9 Mon Sep 17 00:00:00 2001
+From: Steven Elliott <selliott512@gmail.com>
+Date: Sun, 16 Jul 2023 14:52:04 -0400
+Subject: [PATCH] create_caption: Python PIL 10.0.0 support (#1027)
+
+To support Python PIL 10.0.0 this change uses newer API textbbox() when
+available, and older API textsize() when not.
+---
+ graphics/text/create_caption | 17 +++++++++++++++--
+ 1 file changed, 15 insertions(+), 2 deletions(-)
+
+diff --git a/graphics/text/create_caption b/graphics/text/create_caption
+index 7ddbd8d66..22bc0507d 100755
+--- a/graphics/text/create_caption
++++ b/graphics/text/create_caption
+@@ -18,8 +18,21 @@ background_image.load()
+ background_image = background_image.convert("RGBA")
+ image = Image.new("RGBA", background_image.size, (0, 0, 0, 0))
+ draw = ImageDraw.Draw(image)
+-txt1_size = draw.textsize(txt1, font=font)
+-txt2_size = draw.textsize(txt2, font=font)
++
++# Getting the text size is tricky since for newer PIL, such as 10.0.0, only
++# textbbox() is supported, but for older PIL, such 7.2.0, only textsize()
++# is supported. The solution is to default to the newer API, but fallback to
++# the older one when it is not available.
++try:
++ # This newer API returns a four item tuple. The "xy" kwarg is returned in
++ # the first two items, and last two items is the size needed, but with "xy"
++ # added, so passing "(0, 0)" returns the size needed.
++ txt1_size = draw.textbbox(xy=(0, 0), text=txt1, font=font)[2:]
++ txt2_size = draw.textbbox(xy=(0, 0), text=txt2, font=font)[2:]
++except:
++ # This older API simply returns the size needed.
++ txt1_size = draw.textsize(txt1, font=font)
++ txt2_size = draw.textsize(txt2, font=font)
+
+ draw.text(
+ (5, int(image.height - txt1_size[1] - 5)),
diff --git a/games-fps/freedm-data/freedm-data-0.12.1-r1.ebuild b/games-fps/freedm-data/freedm-data-0.12.1-r1.ebuild
index 354720400a4a..29b53f429e6a 100644
--- a/games-fps/freedm-data/freedm-data-0.12.1-r1.ebuild
+++ b/games-fps/freedm-data/freedm-data-0.12.1-r1.ebuild
@@ -20,6 +20,10 @@ BDEPEND="
app-text/asciidoc
games-util/deutex[png]"
+PATCHES=(
+ "${FILESDIR}"/${PN}-0.12.1-Python-PIL-10.0.0-support.patch
+)
+
S="${WORKDIR}/freedoom-${PV}"
DOOMWADPATH=share/doom