【问题标题】:PHP imagettftext() with korean characters are not working带有韩语字符的PHP imagettftext()不起作用
【发布时间】:2023-03-06 21:08:02
【问题描述】:

我正在尝试使用一些文本生成图像,并且我编写了以下代码:

<?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 字符时,它无法正常工作并获取此图像。

知道如何显示韩文吗?

谢谢

【问题讨论】:

    标签: php imagettftext


    【解决方案1】:

    看起来Walkway Black RevOblique.ttf 不是韩文字体。尝试下载并使用韩语版本。

    【讨论】:

    • 嗨。我没有收到任何错误,我的字体路径是正确的。我试过用英文文本,它工作得很好。
    • @Mr.Happy 我随机下载了韩语.ttf 并尝试了您的代码,没有任何更改。有用。也许你的字体不是韩文?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-03-30
    • 2014-11-06
    • 2021-07-27
    • 2023-03-16
    • 1970-01-01
    相关资源
    最近更新 更多