相关疑难解决方法(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
查看次数

使用PIL(Python成像库)使用变音符号("nikud",发声标记)编写文本

使用PIL在图像上编写简单文本很容易.

draw = ImageDraw.Draw(img)
draw.text((10, y), text2, font=font, fill=forecolor )
Run Code Online (Sandbox Code Playgroud)

但是,当我尝试写希伯来语标点符号(称为"nikud"或ניקוד)时,字符不会重叠.(我猜这个问题也与阿拉伯语和其他类似语言有关.)

在支持环境中,这两个词占用相同的空间/宽度(以下示例取决于您的系统,因此图像):

סֶפֶרספר

但是当用PIL绘制文本时,我得到:

סֶפֶר

因为库可能不遵守字距调整(?)规则.

是否可以让字符和希伯来语标点符号占用相同的空间/宽度而无需手动编写字符定位?

image - nikud和字母间距http://tinypic.com/r/jglhc5/5

image url:http://tinypic.com/r/jglhc5/5

python unicode fonts hebrew python-imaging-library

7
推荐指数
2
解决办法
2565
查看次数