diff --git a/Tests/images/bitmap_font_blend.png b/Tests/images/bitmap_font_blend.png index ac97357ab..a5acf3667 100644 Binary files a/Tests/images/bitmap_font_blend.png and b/Tests/images/bitmap_font_blend.png differ diff --git a/Tests/test_imagefont.py b/Tests/test_imagefont.py index 859e39c1c..95e06227a 100644 --- a/Tests/test_imagefont.py +++ b/Tests/test_imagefont.py @@ -862,7 +862,7 @@ def test_bitmap_blend(layout_engine, embedded_color): "Tests/fonts/EBDTTestFont.ttf", size=64, layout_engine=layout_engine ) - im = Image.new("RGB", (128, 96), "white") + im = Image.new("RGBA", (128, 96), "white") d = ImageDraw.Draw(im) d.text((16, 16), "AA", font=font, embedded_color=embedded_color, fill="#8E2F52") diff --git a/src/PIL/ImageDraw.py b/src/PIL/ImageDraw.py index fbf320d72..4d5919f22 100644 --- a/src/PIL/ImageDraw.py +++ b/src/PIL/ImageDraw.py @@ -32,6 +32,7 @@ import math import numbers +import struct from . import Image, ImageColor @@ -542,7 +543,8 @@ class ImageDraw: # font.getmask2(mode="RGBA") returns color in RGB bands and mask in A # extract mask and set text alpha color, mask = mask, mask.getband(3) - color.fillband(3, (ink >> 24) & 0xFF) + ink_alpha = struct.pack("=i", ink)[3] + color.fillband(3, ink_alpha) x, y = coord self.im.paste(color, (x, y, x + mask.size[0], y + mask.size[1]), mask) else: