-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
The parameter direction of ImageDraw.text can't use Chinese sequence #3125
Copy link
Copy link
Closed
Labels
BugAny unexpected behavior, until confirmed feature.Any unexpected behavior, until confirmed feature.Font Rendering
Description
What did you do?
- I try to draw chinese character by following test code
from PIL import Image, ImageDraw, ImageFont
size = 32
font = ImageFont.truetype('./font/simsun.ttf', size)
img = Image.new('RGBA', (size, size), (0, 0, 0, 0))
draw = ImageDraw.Draw(img)
draw.text((0, 0), '我和你', fill='black', direction='ttb')- Futhermore, if I don't use chinese, just english:
from PIL import Image, ImageDraw, ImageFont, features
size = 32
img = Image.new('RGBA', (size, size), (255, 255, 255))
draw = ImageDraw.Draw(img)
draw.text((0, 0), 'abc', fill='black', direction='rtl')What did you expect to happen?
- I want to get the image like that
我
和
你
What actually happened?
- The code can't run successfully. The log is
Traceback (most recent call last):
File "draw_character.py", line 111, in <module>
draw.text((0, 0), '我和你', font=font, fill='black', direction='ttb')
File "/home/xyl/anaconda3/lib/python3.6/site-packages/Pillow-5.0.0-py3.6-linux-x86_64.egg/PIL/ImageDraw.py", line 220, in text
File "/home/xyl/anaconda3/lib/python3.6/site-packages/Pillow-5.0.0-py3.6-linux-x86_64.egg/PIL/ImageFont.py", line 166, in getmask2
RuntimeError: raqm_layout() failed.
The font file can be downloaded in here: https://github.com/micmro/Stylify-Me/blob/master/.fonts/SimSun.ttf
2. I get the image like this:

What versions of Pillow and Python are you using?
python: 3.6.3
pillow: 5.0.0
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
BugAny unexpected behavior, until confirmed feature.Any unexpected behavior, until confirmed feature.Font Rendering
