相关疑难解决方法(0)

将阿拉伯语写入图像时出错

我以前的相关问题:

php使用图像:用阿拉伯语,ttf字体写完整的单词

我的问题是:

  • 如果我想写入????图像,则显示为? ? ? ?
  • 好吧,我修复了它现在输出: ? ? ? ?

使用此功能:

function arab($word){

       $w = explode(' ',$word) ;

       $f = array(array('?','?'),'?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?');

       $t = array(array('?_','?_'),'?_','?_','?_','?_','?_','?_','?_','?_','?_','?_','?_','?_','?_','?_','?_','?_','?_','?_','?_','?_','?_','?_','?_','?_','?_','?_');

       $my_arab = '' ;

       foreach($w as $wo)
        {
             $r  = array() ;

             $wo = str_replace($f , $t ,$wo);

             $ne = explode('_', $wo) ;

             foreach($ne as $new) {
                $new = str_replace('_','',$new) ;
                array_unshift($r , $new);
             }

            $my_arab .=  ' '.implode('',$r) ;

        }

     return trim($my_arab) ;

}
Run Code Online (Sandbox Code Playgroud)

但新问题是:

? ? ? ?

(分开的字母)它应该是: …

php arabic imagettftext

11
推荐指数
2
解决办法
2590
查看次数

如何在图像中写入阿拉伯语或波斯语等非英语字符?

如何使用PHP GD库将阿拉伯语或波斯语字符写入图像?

即"احسان"

php gd

10
推荐指数
1
解决办法
2842
查看次数

使用 PIL(Python 图像库)绘制希伯来语文本时,niqqud 未正确对齐

我正在使用 Pillow / PIL 用 nikud 绘制希伯来字母。我注意到 nikudim(nikud 的复数形式)没有正确对齐,有时会与其他字母重叠。

\n\n

有什么建议的修复方法吗?我尝试了几种字体,它们似乎都有自己的问题。

\n\n

这是我正在使用的代码。

\n\n
from bidi.algorithm import get_display\nfrom PIL import Image, ImageDraw, ImageFont\n\nfonts = [\n    (\'Tammey FranckCLM\', \'/PATH/TO/FONT/TaameyFrankCLM-Medium.ttf\'),\n    (\'Times New Roman\', \'/PATH/TO/FONT/Times New Roman.ttf\'),\n    (\'Arial\', \'/PATH/TO/FONT/Arial.ttf\')\n]\n\nim = Image.new(mode=\'RGBA\', size = (1000, 1000), color = (0, 0, 0, 255))\ndraw = ImageDraw.Draw(im)\n\nheight = 100\nfor f in fonts:\n    fnt = ImageFont.truetype(f[1], 40)\n    text = \'\xd7\xa2\xd6\xb8\xd7\x9c\xd6\xb5\xd7\x99\xd7\xa0\xd7\x95\xd6\xbc\'\n    text_bidi = get_display(text, base_dir=\'R\')\n    draw.text((100, height), f[0], font=fnt, fill=(255, 255, 255))\n    draw.text((500, height), text_bidi, font=fnt, fill=(255, 255, 255))\n …
Run Code Online (Sandbox Code Playgroud)

python hebrew python-imaging-library python-3.x

5
推荐指数
0
解决办法
380
查看次数