0
我使用GD为页面上的标题图像实时生成图像。目前生成的图片超过100张,绝大多数图片效果很好。GD图像生成错误
最近我们发现某些标题打破了在两个字符之间插入大水平空间的图像创建。
用于图像生成的字体是Interstate,下面是一些标题的例子,以及一个破碎的例子。在标题不完整的情况下,相互靠近的字符“JB”破坏了它。翻转它们之间的字符或具有任意数量的字符会导致正确生成图像。
正如你可以从例子中看到的,标题使用短文本和长文本两部分,这只是一个例子,打破它到目前为止,真的开始混淆我,并怀疑字体文件或GD , 有什么建议么?
alt text http://far.id.au/jkf/so/jb.png alt text http://far.id.au/jkf/so/bj.png alt text http://far.id.au/jkf/so/cheesecake.png alt text http://far.id.au/jkf/so/blah.png
代码:
private function GenerateImage()
{
$height = 31;
$width = $this->Width;
$x = 10;
$y = 20;
$font_size = 10;
$text_colours = $this->ToRGB($this->TextColour);
$background_colours = $this->ToRGB($this->BackgroundColour);
$image = imagecreatetruecolor($width,$height);
$fg_color = imagecolorallocate($image,$text_colours[0],$text_colours[1],$text_colours[2]);
$bg_color = imagecolorallocate($image,$background_colours[0],$background_colours[1],$background_colours[2]);
imagefill($image,0,0,$bg_color);
imagettftext($image,$font_size,0,$x,$y,$fg_color,$this->Font,strtoupper($this->Title));
return imagepng($image,$this->FilePath,9);
}
没有任何实际的代码,它主要是猜测。 – Ikke 2009-06-16 06:49:55