You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am using the Python library 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).
While the glyph shapes are correct when rendered, some text is shifted right and consequently clipped by the bounding box. Compare the first rendering below (using Pillow) with the second (in MS Word). I have shown the bounding box in red.
Code to reproduce clipping effect:
#!/usr/bin/python3
# -*- coding: utf-8 -*-
from PIL import Image
from PIL import ImageFont
from PIL import ImageDraw
img = Image.new("RGB", (512, 512), "white")
draw = ImageDraw.Draw(img)
font = ImageFont.truetype("Battambang-Regular.ttf", 60, layout_engine=ImageFont.LAYOUT_RAQM)
text = "លោកុប្បត្តិ"
draw.text((0, 0), text, (0, 0, 0), font=font)
img.save('out.png')
I am using the following versions on Ubuntu 18.04:
Thanks, Khaled. I did wonder whether that might be the case, but I wanted to check whether the offset of the first glyph is given to Pillow by raqm (or FreeType, or something else) as part of the layout.
I am using the Python library 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
).While the glyph shapes are correct when rendered, some text is shifted right and consequently clipped by the bounding box. Compare the first rendering below (using Pillow) with the second (in MS Word). I have shown the bounding box in red.
Code to reproduce clipping effect:
I am using the following versions on Ubuntu 18.04:
Any help would be greatly appreciated. I am not sure whether this issue stems from libraqm or one of the other libraries.
The text was updated successfully, but these errors were encountered: