multline text not supported
Phoenix09 opened this issue · comments
#!/usr/bin/env python3
import aggdraw
from PIL import Image, ImageDraw, ImageFont
im = Image.new("RGBA", (256, 256), (255, 255, 255, 255))
draw = ImageDraw.Draw(im)
font = ImageFont.truetype("/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf", 42)
draw.text((0, 0), "this\nis\nmultiline", font=font, fill=(0, 0, 0))
im.save("Pillow.png")
im = Image.new("RGBA", (256, 256), (255, 255, 255, 255))
draw = aggdraw.Draw(im)
font = aggdraw.Font("black", "/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf", 42)
draw.text((0, 0), "this\nis\nmultiline", font)
draw.flush()
im.save("aggdraw.png")
To be clear, this isn't meant to work and is a missing feature in aggdraw. Looking at PIL's source code it looks like they have a completely separate method for multiline text (possibly added later): https://github.com/python-pillow/Pillow/blob/da39d4034213cae7e575d5e2252d7705080ab796/src/PIL/ImageDraw.py#L264-L409
Pull requests are welcome, but this functionality may be simpler if/when we move to cython as the core aggdraw language.