2011-05-03 76 views
8

了解此问题之前已在 PHP update kerning problem with imagettftext() and imagefttext() functions 但已解决;GD和PHP 5.3中的字距问题

PHP5.3似乎有字距问题打印文本:

在以下实施例看的 'x'(字体:Ubuntu的M.ttf):

PHP5.2,ubuntu的(好)

enter image description here

PHP5.3.2,Ubuntu的(糟糕的是,x被养肥)

PHP5.3.2,MAMP OSX(可怕的)

enter image description here

是否有任何解决这个?

任何有5.3.6安装的人都可以试试这个吗?

问候, //牛逼

+2

这可能不是由于PHP版本,但是捆绑的GD的版本的FreeType库。做一个'phpinfo()',查看版本号并在这里发布 – 2011-05-03 22:00:21

+0

@Pekka:这真的取决于。 PHP通常随附自己定制的GD库,但并非总是如此。例如,Debian不使用捆绑版本,而是使用全局libgd。 – 2011-05-04 09:17:03

+1

@Sander这应该不是关于GD,而是关于Freetype(但可能,你所说的也适用于此 - 它有时会捆绑在一起,有时不会)。无论如何,如果我没有弄错,'phpinfo()'应该总是有正确的数字,捆绑与否 – 2011-05-04 09:19:46

回答

1

我试图下载的字体(Ubuntu的字体家族的0.71.2版本)后,用我家的机器复制的中间图像。 Arch Linux,x86_64,PHP 5.3.6,GD 2.0.34(捆绑),Suhosin补丁,FreeType 2.4.4。我更喜欢e和x。

图像生成:

<?php 
$img = imagecreatetruecolor(158, 72); 
imagesavealpha($img, true); 

$bg = imagecolorallocatealpha($img, 0, 0, 0, 127); 
$black = imagecolorallocate($img, 0, 0, 0); 
imagefill($img, 0, 0, $bg); 

$text = "testar text"; // - was attempt at no aa, like example 
imagettftext($img, 24, 0, 0, 36, -($black), 'Ubuntu-M', $text); 
$text = "med text"; 
imagefttext($img, 24, 0, 12, 72, $black, 'Ubuntu-M', $text); 

imagepng($img, 'test.png'); 
imagedestroy($img); 
?> 

输出:

output of attempt to duplicate second image in question