I want the output to be like this (found at GitHub):
.
But currently I am this:
The skin tone of an emoji gets separated in my output. How do I fix this? Do I need other libraries?
The GitHub code: https://github.com/python-pillow/Pillow/pull/4955
from PIL import Image, ImageDraw, ImageFont
def test(font, out_name):
fnt = ImageFont.truetype(font, size=109, layout_engine=ImageFont.LAYOUT_RAQM)
im = Image.new("RGBA", (600, 600), (100, 100, 100, 100))
draw = ImageDraw.Draw(im)
draw.text((0, 32), "a\u263A", fill="#faa2", embedded_color=True, font=fnt)
draw.text((0, 132), "a\u263A", fill="#faa8", embedded_color=True, font=fnt)
draw.text((0, 232), "a\u263A", fill="#faa", embedded_color=True, font=fnt)
draw.text((0, 332), "\U0001F3AC\U0001F44B\U0001F3FB\U0001F44B\U0001F3FF", fill="white", embedded_color=True, font=fnt)
draw.text((0, 432), "a\u263A", fill="#faa2", font=fnt)
im.show()
im.save(f"testemoji_{out_name}.png")
test(r"C:\Users\Nulano\Downloads\NotoColorEmoji.ttf", "cbdt")
test("seguiemj.ttf", "colr")
My code:
from PIL import Image, ImageDraw, ImageFont
def test(font, out_name):
fnt = ImageFont.truetype(font, size=109, layout_engine=ImageFont.LAYOUT_BASIC,encoding='utf-16')
im = Image.new("RGBA", (800, 600), (100, 100, 100, 0))
draw = ImageDraw.Draw(im)
draw.text((0, 32), "a\u263A",font=fnt, fill="#faa2", embedded_color=True)
draw.text((0, 132), "a\u263A",font=fnt, fill="#faa8", embedded_color=True)
draw.text((0, 232), "a\u263A", fill="#faa",font=fnt, embedded_color=True)
draw.text((0, 332), "\U0001F3AC\U0001F44B\U0001F3FB\U0001F44B\U0001F3FF",font=fnt, fill="white", embedded_color=True)
draw.text((0, 432), "a\u263A",font=fnt, fill="#faa2", embedded_color=True)
im.save(path+"testemoji_{out_name}.png")
return im
# test(path+"Roboto/NotoColorEmoji.ttf", "cbdt")
test(path+"Roboto/seguiemj.ttf", "colr")