我在绘制“杂项符号和象形文字”unicode 块下的表情符号时遇到了问题。
这是一个示例代码:
<?php
header('Content-Type: image/png');
$im = imagecreatetruecolor(290, 60);
$grey = imagecolorallocate($im, 200, 200, 200);
$black = imagecolorallocate($im, 0, 0, 0);
imagefilledrectangle($im, 0, 0, 289, 59, $grey);
$font = 'seguisym.ttf';
$font = realpath($font);
//🌀 is the unicode html entity for a cyclone. It is under 'Miscellaneous Symbols And Pictographs'.
$text = "🌀 is a cyclone!";
imagettftext($im, 20, 0, 5, 22, $black, $font, $text);
//⛄ is the unicode html entity for a snowman. It is under 'Miscellaneous Symbols'.
$text = "⛄ is a snowman!";
imagettftext($im, 20, 0, 5, 52, $black, $font, $text);
imagepng($im);
imagedestroy($im);
?>
这是输出:
这是它的样子:
如您所见,这些表情符号都位于不同的 Unicode 块下。旋风位于“杂项符号和象形文字”下方,绘制的是 HTML 实体而不是实际字符,但雪人位于“杂项符号”下方且绘制正确。我已经仔细检查以确保我使用的字体包含两个字符。
需要明确的是,我希望绘制实际字符而不是 HTML 实体。
呈现为 UTF8 的相同字符: