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

Unicode devanagari fonts rendered incorrectly #4070

Closed
pranphy opened this issue Sep 17, 2019 · 4 comments
Closed

Unicode devanagari fonts rendered incorrectly #4070

pranphy opened this issue Sep 17, 2019 · 4 comments

Comments

@pranphy
Copy link

pranphy commented Sep 17, 2019

Devanagari fonts are not rendered correctly.

from PIL import Image
from PIL import ImageFont, ImageDraw, ImageOps
import matplotlib.pyplot as plt

im=Image.new('L',(500,200))
font = ImageFont.truetype('Laila-Regular.ttf', 85)
                # transpose font optionally
transposed_font = ImageFont.TransposedFont(font)

f = ImageFont.load_default()
txt=Image.new('L', (500,200))
d = ImageDraw.Draw(txt)
d.text( (0, 0), u"राष्ट्रिय दृश्य",  font=font, fill=255)
w=txt.rotate(0,  expand=50)
im.paste( ImageOps.colorize(w, (0,0,0), (255,255,84)), (0,60),  w)
plt.imshow(im)

image
Which should have been rendered as
image
The second image is a screenshot of word processer displaying same two words in the same font.

@radarhere
Copy link
Member

Is this covered by issues #3191 and #2255?

@pranphy
Copy link
Author

pranphy commented Sep 17, 2019

Yes its the same issue as #3191. There doesn't seem to be a solution in that issue as well.

@radarhere
Copy link
Member

Closing as a duplicate.

@radarhere
Copy link
Member

Running the following code with Pillow 10.0.0 with RAQM enabled

from PIL import Image
from PIL import ImageFont, ImageDraw, ImageOps

im=Image.new('L',(500,200))
font = ImageFont.truetype('Laila-Regular.ttf', 85)

f = ImageFont.load_default()
txt=Image.new('L', (500,200))
d = ImageDraw.Draw(txt)
d.text( (0, 0), u"राष्ट्रिय दृश्य",  font=font, fill=255)
w=txt.rotate(0,  expand=50)
im.paste( ImageOps.colorize(w, (0,0,0), (255,255,84)), (0,60),  w)
im.save("out.png")

I get

out

So this looks like it has been resolved.

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

No branches or pull requests

2 participants