php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #10548 function ImageTTFText always get wrong chinese words from TTF ...
Submitted: 2001-04-29 06:00 UTC Modified: 2002-08-13 22:58 UTC
From: cchsieh at gagazone dot net Assigned:
Status: Not a bug Package: GD related
PHP Version: 4.0.4pl1 OS: FreeBSD4
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: cchsieh at gagazone dot net
New email:
PHP Version: OS:

 

 [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);

?>

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-04-30 08:26 UTC] cchsieh at gagazone dot net
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);

?>

 [2001-04-30 08:27 UTC] cchsieh at gagazone dot net
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);

?>

 [2002-08-13 22:58 UTC] kalowsky@php.net
Thank you for taking the time to report a problem with PHP.
Unfortunately you are not using a current version of PHP -- 
the problem might already be fixed. Please download a new
PHP version from http://www.php.net/downloads.php

If you are able to reproduce the bug with one of the latest
versions of PHP, please change the PHP version on this bug report
to the version you tested and change the status back to "Open".
Again, thank you for your continued support of PHP.

and we now bundle our own GD for your chewing enjoyment!
 [2004-06-03 15:39 UTC] benny at masclub dot org
php4.3.6 freebsd 4.9 ports
still have this bug. :(
 [2004-06-04 16:37 UTC] benny at masclub dot org
Freebsd 4.9 with mod_php 4.3.6 ports

ImageTTFText can not get GB2312 font correctly.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Nov 23 00:01:32 2024 UTC