linux CLI:如何将阿拉伯文本呈现为位图 [英] linux CLI: how to render Arabic text into bitmap

查看:145
本文介绍了linux CLI:如何将阿拉伯文本呈现为位图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想用命令行界面将阿拉伯文本绘制到位图(bmp或png)中。

I would like to draw Arabic text into bitmap (bmp or png) with command line interface.

我尝试过imagemagick和RMagick,但是我遇到了RTL语言问题。我所有的渲染都是从左到右。谷歌没有帮助。

I have tried imagemagick and RMagick, but I have problem with RTL language issue. all my rendering are left to right. And google is not helping.

要求:

./render "لوحة المفاتيح" out.png

会给出一个位图:

لوحةالمفاتيح

لوحة المفاتيح

任何人都可以给我一些成功的结果吗?

Anyone can give me some successful results?

推荐答案


任何人都能给我一些成功的结果吗?

Anyone can give me some successful results?

我可以。我从ImageMagick使用 convert

I can. I use convert from ImageMagick:

echo لوحة المفاتيح > text.txt && \
convert -size 300x200 \
        -background white \
        -fill black \
        -font /usr/share/fonts/truetype/droid/DroidNaskh-Regular.ttf \
        -pointsize 24 \
        -gravity Center \
        label:@text.txt \
        text.png

结果如下:

一些注释:


  1. 您需要使用定义已使用字符的字体(在您的情况下为阿拉伯字体)

  2. 始终使用内部文本的临时文件直接从命令行提供文本:它会导致奇怪的结果

更新我没有'注意问题的RTL部分;我认为使用pango我得到了更好的结果(参考):

UPDATE I didn't notice the RTL part of the question; I think I got better results using pango (reference):

# On Ubuntu
sudo apt-get install libpango1.0-dev
echo -n لوحة المفاتيح > text.txt
pango-view text.txt --no-display --output text.png

结果:

这篇关于linux CLI:如何将阿拉伯文本呈现为位图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆