From 054b4da88a8afb4a721d02fdfadcddd2ae843f95 Mon Sep 17 00:00:00 2001 From: Andrew Murray Date: Tue, 18 Aug 2026 09:57:51 +1000 Subject: [PATCH] Remove unneeded code for handling zero-width characters --- Tests/test_font_bdf.py | 7 ------- src/PIL/BdfFontFile.py | 6 +----- 2 files changed, 1 insertion(+), 12 deletions(-) diff --git a/Tests/test_font_bdf.py b/Tests/test_font_bdf.py index 033b5f8fbd5..6ecb1140093 100644 --- a/Tests/test_font_bdf.py +++ b/Tests/test_font_bdf.py @@ -17,13 +17,6 @@ def test_sanity() -> None: assert len([_f for _f in font.glyph if _f]) == 190 -def test_zero_width_chars() -> None: - with open(filename, "rb") as fp: - data = fp.read() - data = data[:2650] + b"\x00\x00" + data[2652:] - BdfFontFile.BdfFontFile(io.BytesIO(data)) - - def test_decompression_bomb() -> None: with open(filename, "rb") as fp: data = fp.read() diff --git a/src/PIL/BdfFontFile.py b/src/PIL/BdfFontFile.py index 098779bfd6e..bc3ed7c29b6 100644 --- a/src/PIL/BdfFontFile.py +++ b/src/PIL/BdfFontFile.py @@ -82,11 +82,7 @@ def bdf_char( (0, 0, width, height), ) - try: - im = Image.frombytes("1", (width, height), bitmap, "hex", "1") - except ValueError: - # deal with zero-width characters - im = Image.new("1", (width, height)) + im = Image.frombytes("1", (width, height), bitmap, "hex", "1") return id, int(props["ENCODING"]), bbox, im