I am trying to use PHP to display some Chinese characters over an image. The code is provided below.
<?php
$im = imagecreatetruecolor(60, 20);
$white = imagecolorallocate($im, 255, 255, 255);
$grey = imagecolorallocate($im, 128, 128, 128);
$black = imagecolorallocate($im, 0, 0, 0);
imagefilledrectangle($im, 0, 0, 60, 20, $white);
$text = '你好';
$font = 'simsun.ttc';
imagettftext($im, 10, 0, 5, 15, $black, $font, $text);
imagepng($im, 'pic.jpg');
imagedestroy($im);
?>
I can display those two Chinese characters on my PC correctly but I cannot display them on my server. When I typed in the following command line, and the warning message showed up.
$ php font.php
PHP Warning: imagettftext(): Could not read font in /usr/share/nginx/html/model/font.php on line 9
I did some search on the internet and found that some said imagettftext may not be able to handle ASCII codes whose values are greater than 127. The point is I am able to display them on my PC. I wonder how I can fix this problem.