From a66effe521c667fd29033a9384c2d9bc95e341da Mon Sep 17 00:00:00 2001 From: Matiiss <83066658+Matiiss@users.noreply.github.com> Date: Mon, 22 Jan 2024 23:09:03 +0200 Subject: [PATCH 1/2] Matiiss update sdl ttf (#2687) * Update SDL_ttf to 2.22.0, add test for a bugfix * Removed calling a surface --- buildconfig/download_win_prebuilt.py | 8 ++++---- .../docker_base/sdl_libs/build-sdl2-libs.sh | 2 +- .../docker_base/sdl_libs/sdl2.sha512 | 2 +- test/font_test.py | 17 +++++++++++++++++ 4 files changed, 23 insertions(+), 6 deletions(-) diff --git a/buildconfig/download_win_prebuilt.py b/buildconfig/download_win_prebuilt.py index cfd6346f5e..da37382218 100644 --- a/buildconfig/download_win_prebuilt.py +++ b/buildconfig/download_win_prebuilt.py @@ -86,8 +86,8 @@ def get_urls(x86=True, x64=True): '983484dd816abf25cdd5bce88ac69dbca1ea713a' ], [ - 'https://github.com/libsdl-org/SDL_ttf/releases/download/release-2.20.2/SDL2_ttf-devel-2.20.2-VC.zip', - 'dee48e9c5184c139aa8bcab34a937d1b3df4f503' + 'https://github.com/libsdl-org/SDL_ttf/releases/download/release-2.22.0/SDL2_ttf-devel-2.22.0-VC.zip', + '2d4f131909af2985b5ebc5ed296d28628c87c243' ], [ 'https://github.com/libsdl-org/SDL_mixer/releases/download/release-2.6.2/SDL2_mixer-devel-2.6.2-VC.zip', @@ -223,12 +223,12 @@ def copy(src, dst): copy( os.path.join( temp_dir, - 'SDL2_ttf-devel-2.20.2-VC/SDL2_ttf-2.20.2' + 'SDL2_ttf-devel-2.22.0-VC/SDL2_ttf-2.22.0' ), os.path.join( move_to_dir, prebuilt_dir, - 'SDL2_ttf-2.20.2' + 'SDL2_ttf-2.22.0' ) ) copy( diff --git a/buildconfig/manylinux-build/docker_base/sdl_libs/build-sdl2-libs.sh b/buildconfig/manylinux-build/docker_base/sdl_libs/build-sdl2-libs.sh index 7df3a14167..1e0b82e628 100644 --- a/buildconfig/manylinux-build/docker_base/sdl_libs/build-sdl2-libs.sh +++ b/buildconfig/manylinux-build/docker_base/sdl_libs/build-sdl2-libs.sh @@ -5,7 +5,7 @@ cd $(dirname `readlink -f "$0"`) SDL2="SDL2-2.28.5" IMG2="SDL2_image-2.8.2" -TTF2="SDL2_ttf-2.20.2" +TTF2="SDL2_ttf-2.22.0" MIX2="SDL2_mixer-2.6.3" diff --git a/buildconfig/manylinux-build/docker_base/sdl_libs/sdl2.sha512 b/buildconfig/manylinux-build/docker_base/sdl_libs/sdl2.sha512 index 7aeac6178d..71b3e49e4e 100644 --- a/buildconfig/manylinux-build/docker_base/sdl_libs/sdl2.sha512 +++ b/buildconfig/manylinux-build/docker_base/sdl_libs/sdl2.sha512 @@ -1,4 +1,4 @@ 12593eb78fcca877a8dfb78cf21a4e6feba7dc87c964de378ac462b36d8e41ecb587222cb41d5f56dd35b838e1b9867b8ae0cf2f4d2a01afaf23ac8c11edc84d SDL2-2.28.5.tar.gz 0ff345824f95158dfa72f83f9d4a540601c178cd759334bf849c14a2920b5330d0763413b58c08b3deba8d3a4ccb6ea2a8159f87efe4cbb0e8ea850f63d09454 SDL2_image-2.8.2.tar.gz 2e9da045d2fdab97236c3901b3d441834a67a47c8851ddfb817c9db6f23ed9fb355a5ef8d2158d0c9959a83934e8cd1b95db8a69eaddf8f7fcca115f01818740 SDL2_mixer-2.6.3.tar.gz -b54e93b100712e3764cd80d4e4b16cd4c2a6853620f675941a4214320b0ee29a583d57ad56cd5fdb5c7a32d7615cbf43bc3fa55337b01623cee7219ebb43667c SDL2_ttf-2.20.2.tar.gz +34a1d210d8f1b1e802139d65ba47e36033bb7881e75a8862c1b1c515565bef85e3d81ee42e952aa664de043debef387ba60088a9cf3ba3297413db39a13af912 SDL2_ttf-2.22.0.tar.gz diff --git a/test/font_test.py b/test/font_test.py index 258506c281..d14d98fc10 100644 --- a/test/font_test.py +++ b/test/font_test.py @@ -318,6 +318,23 @@ def test_render_multiline(self): two_lines = f.render("hello\nworld", False, "black", None, 200) self.assertGreater(two_lines.get_height(), one_line.get_height()) + @unittest.skipIf( + pygame.font.get_sdl_ttf_version() < (2, 22, 0), "bug fixed in SDL_ttf 2.22.0" + ) + def test_render_multiple_newlines(self): + if pygame_font.__name__ == "pygame.ftfont": + return + + f = pygame_font.Font(None, 20) + one_newline = f.render("\n", True, "black", "white") + two_newlines = f.render("\n\n", True, "black", "white") + three_newlines = f.render("\n\n\n", True, "black", "white") + self.assertTrue( + one_newline.get_height() + < two_newlines.get_height() + < three_newlines.get_height() + ) + @unittest.skipIf(IS_PYPY, "pypy skip known failure") # TODO class FontTypeTest(unittest.TestCase): From 6e6d044f9fea9d2fa31633bdc3cd60cf2fb7274b Mon Sep 17 00:00:00 2001 From: Matiiss <83066658+Matiiss@users.noreply.github.com> Date: Tue, 23 Jan 2024 14:07:29 +0200 Subject: [PATCH 2/2] More test cases --- test/font_test.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/font_test.py b/test/font_test.py index d14d98fc10..ffc9e5024c 100644 --- a/test/font_test.py +++ b/test/font_test.py @@ -334,6 +334,8 @@ def test_render_multiple_newlines(self): < two_newlines.get_height() < three_newlines.get_height() ) + self.assertEqual(one_newline.get_height() * 2, two_newlines.get_height()) + self.assertEqual(one_newline.get_height() * 3, three_newlines.get_height()) @unittest.skipIf(IS_PYPY, "pypy skip known failure") # TODO