jay3332 / pilmoji

Pilmoji is a fast and reliable emoji renderer for PIL.
MIT License
77 stars 28 forks source link

Custom emoji not being drawn when the length of its name is 1 letter #24

Closed WitherredAway closed 1 year ago

WitherredAway commented 1 year ago

Code to reproduce

with Image.new("RGBA", (128, 128), (255, 255, 255, 0)) as image:
    with Pilmoji(image) as pilmoji:
        pilmoji.text(
            xy=(0, 0),
            text=f"<:e:664509407421530114>",  # Put literally any custom emoji here with 1 letter name
            fill=(0, 0, 0),
            font=FONT,
            emoji_scale_factor=130,
            emoji_position_offset=(-1, -1),
        )
        image.save("emoji.png", "PNG")

This image will be a blank image: emoji

Now try this with more than 1 letter name

with Image.new("RGBA", (128, 128), (255, 255, 255, 0)) as image:
    with Pilmoji(image) as pilmoji:
        pilmoji.text(
            xy=(0, 0),
            text=f"<:ee:664509407421530114>",
            fill=(0, 0, 0),
            font=FONT,
            emoji_scale_factor=130,
            emoji_position_offset=(-1, -1),
        )
        image.save("emoji.png", "PNG")

The image is finally the expected output: emoji

P.S. I have lost sleep and 5 years off my life because of this absurd bug

WitherredAway commented 1 year ago

It is an easy enough fix on my end (to change the emoji name to 2 letters) but please for the love of god do something about this before i start pulling my own hair out

jay3332 commented 1 year ago

Fixed in https://github.com/jay3332/pilmoji/commit/2df25493407f1d389a18f4b3e9a5fae4bd922f8a, sorry for the headaches this may have caused you

WitherredAway commented 1 year ago

Lmao it's okay, I was memeing. Thanks for the quick fix!