开发者

Fonts working on localhost but not on live server

开发者 https://www.devze.com 2023-02-04 03:06 出处:网络
I am using imagettftext() for creating text over a image. I used times new roman font, the application in working fine on my development machine but not in live environment.

I am using imagettftext() for creating text over a image. I used times new roman font, the application in working fine on my development machine but not in live environment.

Please adivce. Is it due to my dev. machine in windows and live is linux ?

Please Help

Actual problem is text on my locahost appears "Monster" but on live server "Mo nster" this is not only with O but with other alphabets too...

$font = './fonts/times.ttf';    

$bbox = imagettfbbox(30, 0, $font, $word);

$x = $bbox[0] + (imagesx($src) / 2) - ($bbox[4] / 2);
$y = $bbox[1] + (imagesy($src) / 2) - ($bbox[5] / 2)+212;

imagettftext($src, 30, 0, $x, $y, $color, $font, $word);开发者_运维问答

$bbox2 = imagettfbbox(18, 0, $font, $definition);

$x = $bbox2[0] + (imagesx($src) / 2) - ($bbox2[4] / 2);
$y = $bbox2[1] + (imagesy($src) / 2) - ($bbox2[5] / 2)+245;

imagettftext($src, 18, 0, $x, $y, $white, $font, $definition);


I had the same error, and in my case the problem was the font definition extension. It was ttf, not Ttf. Check the case of your file extension.


yes , probably the font is not installed on the linux server (live)


I figured this out a long back, the issue was with php version & As I saw a bug reported regarding the problem & quick fix too

Links are added below

Bug: http://bugs.php.net/bug.php?id=51571

Solution: (without changing PHP version)

http://www.php.net/manual/en/function.imagettftext.php (see solution by sk89q)

Thanks

0

精彩评论

暂无评论...
验证码 换一张
取 消