-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
The parameter direction of ImageDraw.text can't use Chinese sequence #3125
Comments
Hi, I meet the same problem, I try use python2 env to solve the problem but not work. Finally, I change the font to solve it. You can try to use the The code: im = Image.open("./source.jpeg")
font = ImageFont.truetype(font="./华文细黑.ttf", size=40)
draw = ImageDraw.Draw(im)
draw.text(xy=(100, 800), text="2018年5月23日,天气晴。", fill=(0, 0, 0, 0), font=font) |
@lvhuiyang |
@xyl576807077 I think I can't help you because I meet the same problem when I use parameter
Requires libraqm. So, I install libraqm from libraqm's doc but my program can't work yet. If get the solution you can tell me, thanks. |
I got the same bug.
Do someone have some idea? :( |
ok i'm not the only one. |
I think that the following issue of raqm is causing raqm_layout() to fail. However, I think that even if using latest raqm, Pillow cannot works the direction feature for "ttb" correctly. I have checked it using latest raqm, it does not works yet. |
I have suffering the same issue I tried to check various libraqm versions with pillow
from os import path
from PIL import Image, ImageFont, ImageDraw
def test_layout():
image = Image.new('RGBA', (500, 500))
font = ImageFont.truetype(path.join('../../input/fonts/font.otf'), 40)
draw = ImageDraw.Draw(image, 'RGBA')
draw.text((0, 0), 'test', font=font, fill='#000000', direction='ttb')
image.show()
test_layout() |
Should this be reported to https://github.com/HOST-Oman/libraqm? |
@hugovk
|
And i also found some error of documentation check follows link
(top to bottom) or ‘btt’ option doesn't work in
|
@KennethanCeyer Good find, Raqm doesn't support |
Is it some kind a bug of Lines 462 to 467 in 3cf6ad1
? or just |
@KennethanCeyer what font are you using in your example - 'input/fonts/font.otf'? |
@radarhere I've tried today again with follows code in MacOS. and These issues seem to be still existed from os import path
from PIL import Image, ImageFont, ImageDraw
def test_layout():
image = Image.new('RGBA', (500, 500))
font = ImageFont.truetype(path.join('/Library/Fonts/Arial.ttf'), 40)
draw = ImageDraw.Draw(image, 'RGBA')
draw.text((0, 0), 'test', font=font, fill='#000000', direction='ttb')
image.show()
test_layout() As you can see, I've tested with Truetype font, Arial.ttf >>> import PIL
>>> print(PIL.__version__)
6.0.0 |
I've created PR #3856 to resolve the problem from @KennethanCeyer. |
#3856 has been merged. From the original post, 1 should be solved. Here is my slightly adjusted code - from PIL import Image, ImageDraw, ImageFont
font = ImageFont.truetype('SimSun.ttf', 32)
im = Image.new('RGBA', (100, 100), (0, 0, 0, 0))
draw = ImageDraw.Draw(im)
draw.text((0, 0), '我和你', 'black', font, direction='ttb')
im.save('out.png') |
With regards to 2 in the original post, I don't think this is how rtl works. English characters are strong characters, and have a definite directionality. However, weak characters, such as arithmetical symbols, do not and are able to be shown right-to-left by Pillow. from PIL import Image, ImageDraw, ImageFont
font = ImageFont.truetype('SimSun.ttf', 32)
im = Image.new('RGBA', (100, 100), (0, 0, 0, 0))
draw = ImageDraw.Draw(im)
draw.text((0, 0), '+-=', 'black', font, direction='rtl')
im.save('out.png') Since your goal surely isn't just to show English characters in reverse, there's not a specific situation to help with here. If anyone has any further thoughts, feel free to comment, and this can be re-opened. |
You're the hero! I will check the new version of Pillow and their result by build on your #3856 PR's source code as soon as possible Yeah In this issue, The rtl option is not the main topic Maybe that issue should be treated at another new issue |
The |
What did you do?
What did you expect to happen?
What actually happened?
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?
The text was updated successfully, but these errors were encountered: