關於imagettftext亂碼的問題

來源:互聯網
上載者:User

imagettftext函數在windows下中文顯示正常,在linux下中文就出現了亂碼。。。
核心代碼如下:

//此處省略N行。。。$image = imagecreatetruecolor($width, $height);$color = imagecolorallocate($image, $red, $green, $blue);imagefill($image, 0, 0, $color);$tcolor = imagecolorallocate($image, $tred, $tgreen, $tblue);//imagestring ($image,  $fontfile,  20 ,  20 ,  "Hello world!" ,  $tcolor);//echo floor(($height - $fontinfo['height']) / 2);die;imagettftext($image, $tsize, 0, ($width - $fontinfo['width']) / 2, $height / 2, $tcolor, $fontfile, $text);//此處省略N行。。。

轉碼什麼的都試過了,不行!也覺得不是編碼的問題。。。
linux下也已經安裝了msyh.ttf字型。。。

windows下顯示:

linux下顯示:

還望各位兄弟姐妹看看,小弟先謝過了!

回複內容:

imagettftext函數在windows下中文顯示正常,在linux下中文就出現了亂碼。。。
核心代碼如下:

//此處省略N行。。。$image = imagecreatetruecolor($width, $height);$color = imagecolorallocate($image, $red, $green, $blue);imagefill($image, 0, 0, $color);$tcolor = imagecolorallocate($image, $tred, $tgreen, $tblue);//imagestring ($image,  $fontfile,  20 ,  20 ,  "Hello world!" ,  $tcolor);//echo floor(($height - $fontinfo['height']) / 2);die;imagettftext($image, $tsize, 0, ($width - $fontinfo['width']) / 2, $height / 2, $tcolor, $fontfile, $text);//此處省略N行。。。

轉碼什麼的都試過了,不行!也覺得不是編碼的問題。。。
linux下也已經安裝了msyh.ttf字型。。。

windows下顯示:

linux下顯示:

還望各位兄弟姐妹看看,小弟先謝過了!

%e6%88%91urlencode('我')的結果,是不是通過URL進行參數傳遞沒有解碼的問題。
我很奇怪windows上是白色的,怎麼Linux下就黃了。。

圖片浮水印出現亂碼,一般是兩個問題。

  • 文本編碼是否統一為utf8

  • GD庫是否啟用JIS-mapped Japanese Font Support

編碼不統一,那就統一一下,啟用JIS-mapped Japanese Font Support了,就關閉即可。

什嗎?你說JIS-mapped Japanese Font Support怎麼關閉?

我的方法是重新編譯php-gd拓展。

確認過了
檔案編碼是一致的;
編譯參數沒有加 --enable-gd-jis-conv的;
windows下測試正常就直接上傳到linux伺服器了。。。

  • 相關文章

    聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.