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
Clipping when rendering Khmer text using Pillow and libraqm #3235
Comments
From the raqm issue:
|
Thanks for linking the raqm issue, Hugo. This is still a problem. Does anyone know what is causing the issue? |
Confirmed that this is still a problem with Pillow 5.5.0 and libraqm 0.5.0. Does anyone know where to start looking? |
From #597, I find that the widths are different if Unicode numbers are used instead of characters. Neither is correct though. from PIL import Image, ImageDraw, ImageFont
img = Image.new('L', (300, 130))
d = ImageDraw.Draw(img)
font = ImageFont.truetype("KhmerOS.ttf", 30)
d.text((50, 30), u'\u179f\u17d2\u1793\u17b6', fill=(255), font=font)
d.text((150, 30), u'ស្នាក់', fill=(255), font=font)
img.save('test.tif') |
I've created PR #3787 to resolve this. |
Perfect. Thank you. PR #3787 fixes the issue I have been having. Here is the original text with correct layout using the new code: |
What did you do?
I used Pillow (5.3.0) to draw Khmer text onto an image using libraqm (0.5.0) for complex layout support (
layout_engine=ImageFont.LAYOUT_RAQM
).What did you expect to happen?
I expected the word "លោកុប្បត្តិ" to be rendered like this (output from MS Word):
What actually happened?
The left offset of the text was too large and resulted in clipping on the right-hand side of the bounding box (shown in red):
Depending on how many glyphs of the word I chose to render, the offset became larger.
What versions of Pillow and Python are you using?
I am using the following versions on Ubuntu 18.04:
Code to reproduce clipping effect:
The text was updated successfully, but these errors were encountered: