2
我试图生成一些文本图像,我已经写了下面的代码:PHP imagettftext()与韩国语字符不工作
<?php
// Set the content-type
header('Content-Type: image/png');
// Create the image
$im = imagecreatetruecolor(400, 30);
// Create some colors
$white = imagecolorallocate($im, 255, 255, 255);
$grey = imagecolorallocate($im, 128, 128, 128);
$black = imagecolorallocate($im, 0, 0, 0);
imagefilledrectangle($im, 0, 0, 399, 29, $white);
// The text to draw
$text = '준수';
// Replace path by your own font path
$font = 'fonts/Walkway Black RevOblique.ttf';
// Add the text
imagettftext($im, 20, 0, 10, 20, $black, $font, $text);
// Using imagepng() results in clearer text compared with imagejpeg()
imagepng($im);
imagedestroy($im);
?>
现在,当我与English
字符文本添加它的工作原理,但是当我用Korean
字符无法正常工作并获取此图像。
任何想法如何显示韩国文字?
感谢
嗨。我没有得到任何错误,我的字体路径是正确的。我已经尝试过使用英文文本,并且它的工作非常完美。 –
我也尝试过'arial.ttf'字体 –
@ Mr.Happy我下载了随机韩文'.ttf',并且没有任何改变就试过了你的代码。有用。也许你的字体不是韩文? –