PHP-韩语字符未使用UTF-8转换

PHP-韩语字符未使用UTF-8转换,php,utf-8,imagettftext,Php,Utf 8,Imagettftext,我通过在图像上添加名称生成图像,但韩文文本显示不正确 我尝试在html上添加,但无法看到实际的文本준석 김 我使用ajax调用以下函数来生成图像 public function CreateMyCertificate() { if (Auth::check()) { $MyScratchProjects = new MyScratchProjects(); if(ctype_digit($_POST['id'])) {

我通过在图像上添加名称生成图像,但韩文文本显示不正确

我尝试在html上添加
,但无法看到实际的文本
준석 김

我使用ajax调用以下函数来生成图像

public function CreateMyCertificate()
    {
        if (Auth::check()) {
            $MyScratchProjects = new MyScratchProjects();

            if(ctype_digit($_POST['id'])) {
                if(isset($_POST['id']) && !empty($_POST['id'])) {
                    $DiplomaIdx = $_POST['id'];
                } else {
                    $DiplomaIdx = "0";
                }

                $GetMyDiploma = $MyScratchProjects->GetMyDiploma($DiplomaIdx);

                $CertificatePath = url().'/public/upload/diplomas/certificate/'.$GetMyDiploma[0]->CertificateTemplate; // Get certificate
                $FileExt = pathinfo($CertificatePath, PATHINFO_EXTENSION);
                $Name = $GetMyDiploma[0]->FirstName.' '.$GetMyDiploma[0]->LastName; // Get user first & last name
                $CertificateName = strtolower($GetMyDiploma[0]->Title).'-certificate'; // Get user first & last name
                //$Name = "Wonkyu Kim";
                $SourceFile = $CertificatePath;

                //Set the Content Type
                //header('Content-type: image/jpeg');

                // Copy and resample the imag
                list($Width, $Height) = getimagesize($SourceFile);
                $ImageP = imagecreatetruecolor($Width, $Height);
                if (strtolower($FileExt) == 'png') {
                    $Image = imagecreatefrompng($SourceFile);
                } else if(strtolower($FileExt) == 'jpeg') {
                    $Image = imagecreatefromjpeg($SourceFile);
                } else if(strtolower($FileExt) == 'gif') {
                    $Image = imagecreatefromgif($SourceFile);
                } else {
                    $Image = imagecreatefromjpeg($SourceFile);
                }

                imagecopyresampled($ImageP, $Image, 0, 0, 0, 0, $Width, $Height, $Width, $Height);

                // Prepare font size and colors
                $TextColor = imagecolorallocate($ImageP, 129, 112, 167);
                $BgColor = imagecolorallocate($ImageP, 129, 112, 167);
                $Font = 'resources/assets/front/fonts/Roboto-Bold-webfont.ttf';
                $FontSize = 27;

                // Set the offset x and y for the text position
                $OffsetX = 0;
                $offsetY = 20;

                // Get the size of the text area
                $Dims = imagettfbbox($FontSize, 0, $Font, $Name);
                $TextWidth = $Dims[4] - $Dims[6] + $OffsetX;
                $TextHeight = $Dims[3] - $Dims[5] + $offsetY;

                // Add text
                //imagettftext($ImageP, $FontSize, 0, $OffsetX, $offsetY, $TextColor, $Font, $text);
                imagettftext($ImageP, $FontSize, 0, 270, 215, $TextColor, $Font, $Name);

                // Save the picture
                ob_start();
                imagepng($ImageP);

                $Base64ImgData = base64_encode(ob_get_clean());

                $html = '<meta http-equiv="content-type" content="text/html; charset=UTF-8" /><div class="modal-body">
                    <div class="certificate_model_container">
                        <div class="model_inner_container">
                            <div class="find_inner_logo">
                                <img alt="edito" src="'.url().'/resources/assets/front/images/Logo_inner.png">
                                <h5>'.$GetMyDiploma[0]->Title.'</h5>
                            </div>
                            <div class="model_img_dv">';
                                $html .= '<a href="data:image/png;base64,'.$Base64ImgData.'" class="none download-my-certificate" download="'.$CertificateName.'.png"></a>';
                                $html .= '<img class="myImage" src="data:image/png;base64,'.$Base64ImgData.'"  alt="'.$GetMyDiploma[0]->Title.'">';
                                $html .= '<p>'.MyFuncs::DateFormat($GetMyDiploma[0]->AwardedOn).'</p>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="modal-footer regiter_btns img_certi_ftr">
                    <div class="find_acc_btn_contianer re_container">
                        <button class="download" type="button">'.trans('messages.my_story.download').'</button>
                        <button class="btn_2" type="button">'.trans('messages.my_story.print').'</button>
                        <button data-dismiss="modal" class="" type="button">'.trans('messages.my_story.close').'</button>
                    </div>
                </div>';

                // Clear
                imagedestroy($Image);
                imagedestroy($ImageP);

                echo $html;
            }

        }
公共函数CreateMyCertificate()
{
if(Auth::check()){
$MyScratchProjects=新的MyScratchProjects();
如果(ctype_位($_POST['id'])){
如果(isset($\u POST['id'])和&!empty($\u POST['id'])){
$emplicaidx=$_POST['id'];
}否则{
$IDX=“0”;
}
$GetMyDiplificate=$MyScratchProjects->GetMyDiplificate($ComplicateIDX);
$CertificatePath=url()。/public/upload/Certificates/certificate/。$GetMyDiplificate[0]>CertificateTemplate;//获取证书
$FileExt=pathinfo($CertificatePath,pathinfo_扩展名);
$Name=$GetMyDiplificate[0]->FirstName.'.$GetMyDiplificate[0]->LastName;//获取用户的名字和姓氏
$CertificateName=strtolower($GetMyDiplificate[0]->Title)。'-certificate';//获取用户的名字和姓氏
//$Name=“Wonkyu Kim”;
$SourceFile=$CertificatePath;
//设置内容类型
//标题(“内容类型:图像/jpeg”);
//复制并重新采样图像
列表($Width,$Height)=getimagesize($SourceFile);
$ImageP=IMAGECreateTureColor($Width,$Height);
如果(strtolower($FileExt)='png'){
$Image=imagecreatefrompng($SourceFile);
}else if(strtolower($FileExt)='jpeg'){
$Image=imagecreatefromjpeg($SourceFile);
}else if(strtolower($FileExt)='gif'){
$Image=imagecreatefromformgif($SourceFile);
}否则{
$Image=imagecreatefromjpeg($SourceFile);
}
imagecopyresampled($ImageP,$Image,0,0,0,0,$Width,$Height,$Width,$Height);
//准备字体大小和颜色
$TextColor=imagecolorallocate($ImageP,129112167);
$BgColor=imagecolorallocate($ImageP,129112167);
$Font='resources/assets/front/fonts/Roboto Bold webfont.ttf';
$FontSize=27;
//设置文本位置的偏移x和y
$OffsetX=0;
$offsetY=20;
//获取文本区域的大小
$Dims=imagettfbbox($FontSize,0,$Font,$Name);
$TextWidth=$Dims[4]-$Dims[6]+$OffsetX;
$TextHeight=$Dims[3]-$Dims[5]+$offsetY;
//添加文本
//imagettftext($ImageP、$FontSize、0、$OffsetX、$offsetY、$TextColor、$Font、$text);
imagettftext($ImageP、$FontSize、0、270、215、$TextColor、$Font、$Name);
//保存图片
ob_start();
imagepng($ImageP);
$Base64ImgData=base64_编码(ob_get_clean());
$html='1
“.$GetMyDiplication[0]->头衔。”
';
$html.='';
$html.='Title.''>';
$html.=''.MyFuncs::DateFormat($GetMyDiplication[0]->AwardedOn)。'

“.trans('messages.my_story.download')。” “.trans('messages.my_story.print')。” “.trans('messages.my_story.close')。” '; //清楚的 图像销毁($图像); imagedestroy($ImageP); echo$html; } }