python - 如何强制阿拉伯字符分开?
问题描述
我正在尝试使用枕头在图像上键入一组没有空格的阿拉伯字符。我目前遇到的问题是,一些阿拉伯字符在彼此相邻时会出现不同的显示。((例如س
,当彼此相邻时,<code>ل将是<code>سل。)我试图以某种方式强制我的字体设置始终分隔所有字符而不注入任何其他字符,我该怎么办?
这是我的代码片段:
#font is an arabic font, and font_path is pointing to that location.
font = ImageFont.truetype(
font=font_path, size=size,
layout_engine=ImageFont.LAYOUT_RAQM)
h, w = font.getsize(text, direction='rtl')
offset = font.getoffset(text)
H, W = int(1.5 * h), int(1.5 * w)
imgSize = H, W
img = Image.new(mode='1', size=imgSize, color=0)
draw = ImageDraw.Draw(img)
pos = ((H-h)/2, (W-w)/2)
draw.text(pos, text, fill=255, font=font,
direction='rtl', align='center')
解决方案
推荐阅读
- reactjs - 如何在反应函数组件中使用jquery调用“.hidden.bs.dropdown”事件
- php - 使用 eloquent 关系显示“结果”而不是“id”时出现错误,以防该字段是可选的,并留空 - Laravel
- c++ - streambuf 如何将错误通知其所有者
- c - 指针不接收 arr 的值
- java - 不能在子类 JAVA 和一个子类中调用超类的方法
- r - 向干涉图中添加强度梯度
- python - 如何在 Python 中同时运行多个循环?
- python - 缺少 1 个必需的位置参数:“ctx”
- c++ - 这个 UTF-8 格式的 BOM 不正确吗?
- html - 如何在 WP 块编辑器工具栏按钮中的 span 标签上添加 id 属性