|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2001-04-29 06:00 UTC] cchsieh at gagazone dot net
About Image function - ImageTTFText: always get wrong chinese words from TTF.
To correct the problem:
$ diff gdttf.c.orig gdttf.c
690c690
< ch = (ch * 256) + **next;
---
> ch = (ch * 256) + ((**next) & 255);
Script to test:
<?php
// Create the image
$png = ImageCreate(200,200);
$bg = ImageColorAllocate($png,0,0,0);
$tx = ImageColorAllocate($png,255,128,128);
// Set Chinese words ("Chinese language" in Chinese Big5)
$string="????";
// Chinese test (need mingli.ttf from MS-Win Chinese ver)
ImageTTFText($png,30,0,0,100,$tx,"/home/staff/cchsieh/public_html/gd/mingli.ttf
// Send the image
header("content-type: image/png\n\n");
ImagePng($png);
// Destroy image
ImageDestroy($png);
?>
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Oct 28 15:00:02 2025 UTC |
About Image function - ImageTTFText: always get wrong chinese words from TTF. To correct the problem: 690c690 < ch = (ch * 256) + **next; --- > ch = (ch * 256) + ((**next) & 255); 705c705,709 < *advance = glyph->metrics.advance; --- > > if ( !font->have_char_map_Unicode && (ch < 161) ) > *advance = glyph->metrics.advance / 2; > else > *advance = glyph->metrics.advance; Script to test: <?php // Create the image $png = ImageCreate(200,200); $bg = ImageColorAllocate($png,0,0,0); $tx = ImageColorAllocate($png,255,128,128); // Set Chinese words ("Chinese language" in Chinese Big5) $string="????"; // Chinese test (need mingli.ttf from MS-Win Chinese ver) ImageTTFText($png,30,0,0,100,$tx,"/home/staff/cchsieh/public_html/gd/mingli.ttf // Send the image header("content-type: image/png\n\n"); ImagePng($png); // Destroy image ImageDestroy($png); ?>About Image function - ImageTTFText: always get wrong chinese words from TTF. To correct the problem: 690c690 < ch = (ch * 256) + **next; --- > ch = (ch * 256) + ((**next) & 255); 705c705,709 < *advance = glyph->metrics.advance; --- > > if ( !font->have_char_map_Unicode && (ch < 161) ) > *advance = glyph->metrics.advance / 2; > else > *advance = glyph->metrics.advance; Script to test: <?php // Create the image $png = ImageCreate(200,200); $bg = ImageColorAllocate($png,0,0,0); $tx = ImageColorAllocate($png,255,128,128); // Set Chinese words ("Chinese language" in Chinese Big5) $string="????"; // Chinese test (need mingli.ttf from MS-Win Chinese ver) ImageTTFText($png,30,0,0,100,$tx,"/home/staff/cchsieh/public_html/gd/mingli.ttf // Send the image header("content-type: image/png\n\n"); ImagePng($png); // Destroy image ImageDestroy($png); ?>