Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Render text and emoji with colors #6514

Closed
CandreaA opened this issue Aug 21, 2022 · 2 comments
Closed

Render text and emoji with colors #6514

CandreaA opened this issue Aug 21, 2022 · 2 comments

Comments

@CandreaA
Copy link

CandreaA commented Aug 21, 2022

What did you do?

textwrapped = "Hello, world! 👋 Here are some emojis: 🎨 🌊 😎"
font = ImageFont.truetype(THIS_FOLDER+"/fonts/seguiemj.ttf", font_size) //merged font
d.text((int(qx),int(qy)), text=textwrapped, align="center", fill="#fff", font=font)

What did you expect to happen?

Render text and emoji with colors

What actually happened?

white emojis: https://imgur.com/a/Exq6aYe

if i use embedded_color=True
i get:

    d.text((int(qx),int(qy)), text=textwrapped, align="center", fill="#fff", font=font, embedded_color=True)
  File "C:\Users\user\AppData\Local\Programs\Python\Python310\lib\site-packages\PIL\ImageDraw.py", line 409, in text
    return self.multiline_text(
  File "C:\Users\user\AppData\Local\Programs\Python\Python310\lib\site-packages\PIL\ImageDraw.py", line 563, in multiline_text
    self.text(
  File "C:\Users\user\AppData\Local\Programs\Python\Python310\lib\site-packages\PIL\ImageDraw.py", line 498, in text
    draw_text(ink)
  File "C:\Users\user\AppData\Local\Programs\Python\Python310\lib\site-packages\PIL\ImageDraw.py", line 480, in draw_text
    self.im.paste(color, coord + coord2, mask)
TypeError: 'float' object cannot be interpreted as an integer

What are your OS, Python and Pillow versions?

  • OS: Windows 10,
  • Python: 3.10
  • Pillow: 9.2
@CandreaA
Copy link
Author

CandreaA commented Aug 21, 2022

Well, the problem was that i can't use "align=center" property together with "embedded_color=True". is it normal?
If i remove "align=center" it works correctly as you can see here: https://imgur.com/a/rLnenPj

@CandreaA
Copy link
Author

i opened another issue #6515

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant