0
txt3 = f"{str(member.name)}"
font3 = ImageFont.truetype("./font/arial.ttf", fontsize3)
draw.text((35,35), txt3, font=font3, fill=(255, 255, 255))

Alright, so here is the issue. The above works fine, like it should. Here is a scenario where the code is used for people with a normal name:

enter image description here

So, that's all good. However when I use the command on a user with a unique/fancy name, it throws this at me.

enter image description here

It's just throwing boxes. I was trying to imitate an API for rank cards. The thing is that, the API also uses arial (I asked the API's owner) but it can show the name correctly while when using PIL, it fails. Thus I believe the issue is with PIL and not the font I am using. Is there any way I can fix this. (For reference purpose, I will put the image made using the API call below)

enter image description here

Any help is appreciated!

Harukomaze
  • 462
  • 4
  • 9
  • 1
    Possible duplicate of: [Unicode characters not rendering with PIL ImageFont](https://stackoverflow.com/questions/18729148/unicode-characters-not-rendering-with-pil-imagefont) – Łukasz Kwieciński Mar 08 '21 at 11:45
  • Issue could also be that during script execution the unicode character information is lost. PIL might work but it fails beforehand. I'd log out the string a couple of times during code and see if it gets displayed there properly. – Tin Nguyen Mar 08 '21 at 11:51
  • `txt3.decode('utf-8')` – Billy Mar 08 '21 at 12:26

1 Answers1

2

You need to use a Unicode font for that. For example Arial Unicode MS.

With Arial: https://i.stack.imgur.com/XWSBO.png

With Arial Unicode: https://i.stack.imgur.com/FfvXP.png

Hajime
  • 21
  • 3