我以前的相关问题:
我的问题是:
????图像,则显示为? ? ? ?? ? ? ?使用此功能:
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)
但新问题是:
? ? ? ?
(分开的字母)它应该是: …
使用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