Round box position to integer when pasting embedded color

This commit is contained in:
Andrew Murray 2022-08-22 12:14:54 +10:00
parent 4c59f77e37
commit 54b01f55f8
3 changed files with 16 additions and 0 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

View File

@ -960,6 +960,21 @@ class TestImageFont:
assert_image_similar_tofile(im, "Tests/images/standard_embedded.png", 6.2)
def test_multiline_centered_embedded_color(self):
txt = "Hello\nWorld!"
ttf = ImageFont.truetype(FONT_PATH, 40, layout_engine=self.LAYOUT_ENGINE)
ttf.getbbox(txt)
im = Image.new("RGB", (160, 96), "white")
d = ImageDraw.Draw(im)
d.multiline_text(
(10, 10), txt, font=ttf, fill="#fa6", align="center", embedded_color=True
)
assert_image_similar_tofile(
im, "Tests/images/standard_embedded_multiline_centered.png", 6.2
)
def test_cbdt(self):
try:
font = ImageFont.truetype(

View File

@ -482,6 +482,7 @@ class ImageDraw:
# extract mask and set text alpha
color, mask = mask, mask.getband(3)
color.fillband(3, (ink >> 24) & 0xFF)
coord = tuple(int(c) for c in coord)
coord2 = coord[0] + mask.size[0], coord[1] + mask.size[1]
self.im.paste(color, coord + coord2, mask)
else: