2

I am trying to generate image with some text and I have wrote following code:

<?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);
?>

Now when I add text with English characters it works but when I used Korean characters is not working and getting this image.

enter image description here

Any idea how to display Korean text?

Thanks

Mr.Happy
  • 2,639
  • 9
  • 40
  • 73

1 Answers1

0

Looks like Walkway Black RevOblique.ttf is not Korean font. Try to download and use Korean one.

vl.lapikov
  • 756
  • 7
  • 12
  • Hi. I am not getting any error and my font path is correct. I have tried with English text and it is working perfect. – Mr.Happy Apr 26 '16 at 14:22
  • @Mr.Happy I downloaded random korean `.ttf` and tried your code without any changes. It works. Maybe your font is not korean? – vl.lapikov Apr 26 '16 at 14:26