2016-04-26 81 views
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字符無法正常工作並獲取此圖像。

enter image description here

任何想法如何顯示韓國文字?

感謝

回答

0

貌似Walkway Black RevOblique.ttf是不是韓國字體。嘗試下載並使用韓文版。

+0

嗨。我沒有得到任何錯誤,我的字體路徑是正確的。我已經嘗試過使用英文文本,並且它的工作非常完美。 –

+0

我也嘗試過'arial.ttf'字體 –

+0

@ Mr.Happy我下載了隨機韓文'.ttf',並且沒有任何改變就試過了你的代碼。有用。也許你的字體不是韓文? –