php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #25132 if compiled with --enable-gd-native-ttf images with ->accents show font errors
Submitted: 2003-08-18 12:50 UTC Modified: 2003-08-26 00:59 UTC
Votes:5
Avg. Score:3.6 ± 0.8
Reproduced:3 of 3 (100.0%)
Same Version:1 (33.3%)
Same OS:1 (33.3%)
From: mail_fidel at yahoo dot com Assigned: pajoye (profile)
Status: No Feedback Package: GD related
PHP Version: 4.3.3RC2 OS: FreeBSD 4.7
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: mail_fidel at yahoo dot com
New email:
PHP Version: OS:

 

 [2003-08-18 12:50 UTC] mail_fidel at yahoo dot com
Description:
------------
If when compiling you use the: --enable-gd-native-ttf then you will have trouble with accents in graphics.

The behavior is as follows:

Lets say you want an image with the words: "hello world". I works as espected and you get the text right.

Now if you want the words: "buen d?a" (pay attention to the accent over the "i") then, the text that displays on the image is "buen d a" not only the accented charanter disapeared but also the next character.

If you remove the config option (--enable-gd-native-ttf) then php behaves as before.



Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-08-18 15:14 UTC] pajoye@php.net
hello,

do you have the ttf font used by your script?

What do you mean by "not only the accented charanter disapeared but also the next character"? 

"buen d?a" and "buen d a",only the "i" disapeared.

Which freetype version do you use?

pierre
 [2003-08-18 18:31 UTC] pajoye@php.net
everythings works fine here. Using bundled GD library, freetype 2.1.3 and the standart arial windows font.

Send the required infos asap if you still reproduce this bug using freetype2 (last release or 2.1.3+) and bundled GD.

pierre


 [2003-08-19 10:27 UTC] mail_fidel at yahoo dot com
This are the config options:

Configure Command =>  './configure' '--enable-versioning' '--enable-memory-limit' '--with-layout=GNU' '--with-zlib-dir=/usr' '--disable-a
ll' '--with-regex=php' '--enable-discard-path' '--enable-bcmath' '--enable-ctype' '--with-dom=/usr/local' '--with-dom-xslt=/usr/local' '-
-with-dom-exslt=/usr/local' '--enable-filepro' '--with-gd' '--with-freetype-dir=/usr/local' '--with-jpeg-dir=/usr/local' '--with-png-dir=
/usr/local' '--with-xpm-dir=/usr/local' '--with-imap=/usr/local' '--with-imap-ssl=/usr/local' '--enable-mbstring' '--enable-mbregex' '--w
ith-mysql=/usr/local' '--enable-overload' '--with-pcre-regex=yes' '--enable-posix' '--with-readline' '--enable-session' '--enable-tokeniz
er' '--enable-xml' '--with-expat-dir=/usr/local' '--with-zlib=yes' '--prefix=/usr/local' 'i386-portbld-freebsd4.7'

This is my working built, without  --enable-gd-native-ttf 

Freetype version:

 freetype2-2.1.4_1

Example code:

  function getImage($font,$string,$point,$color,$bgcolor)
  {

    $ses = session_id();
    $fileName = $ses."_.png";

    $measures = imagettfbbox ( $point, "0", $this->fonts_path.$font, $string);

    $width = abs($measures[4] - $measures[0])+20;
    $upper = abs($measures[5])+5;
    $under = abs($measures[1])+5;
    $height = $upper + $under;

    $image = imagecreate($width, $height);

    //Allocate some colors.
    $color = eregi_replace("#","",$color);
    $ri = hexdec(substr($color, 0, 2));
    $gi = hexdec(substr($color, 2, 2));
    $bi = hexdec(substr($color, 4, 2));
  
    $bgcolor = eregi_replace("#","",$bgcolor);
    $rb = hexdec(substr($bgcolor, 0, 2));
    $gb = hexdec(substr($bgcolor, 2, 2));
    $bb = hexdec(substr($bgcolor, 4, 2));
  
    $bg_color = imagecolorallocate($image,$rb ,$gb,$bb);
  
    $typeface_color = imagecolorallocate($image, $ri, $gi, $bi);
      
    imagecolortransparent($image,$bg_color);
  
    imagefilledrectangle($image, 0, 0, $width, $height, $bg_color);
      
    imagettftext($image, $point, 0, 10, $upper+2, $typeface_color,$this->fonts_path.$font, $string);

    $path = $this->temp_path;

    imagepng($image,$path.$fileName);

    //Finally, free up the memory allocated for the image.

    imagedestroy($image);
    return($fileName);
  }

when trying to solve the problem we change the image type from png to gif to jpg to see if this was the problem. We upgrade freetype and GD. Then I read that php 4.3.3 was using some "recomended" native gd code and when I saw the  --enable-gd-native-ttf I decided to turned off and the scripts start working again.

I'm sure is not a font related problem, first because it worked just before the update, and second bacause we have a big library of ttf fonts and we test it with all of them (since some fonts do not have accent characters we generate an image with each one to test them)

Also, I made a mistake in the description with the example "buen d?a" the output was "buen d ". A customer of us wrote this "todo por tus c?lulas" and the output was: "todo por tus c ulas". If any one knows spanish he/she can realize how embarrassing and funny is is (original text "all for your cells" output text "all for you ass").
 [2003-08-21 06:33 UTC] pajoye@php.net
Can you try this simple script instead?

$im = imagecreatetruecolor(200,200);
$black = imagecolorallocate($im, 255,0,0);
imagettftext($im, 20, 0, 10, 20, $black, "arial.ttf",
  "buen d?a");
imagepng($im, 'res.png');

On which platform do you work?

pierre
 [2003-08-26 00:59 UTC] sniper@php.net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Open". Thank you.


 [2009-11-11 10:27 UTC] itsme at tomkiss dot net
Just to report - I have also experienced this problem on varying 
versions of PHP (5.2.6 on MAMP on Mac and 5.2.11 on CentOS).

The example script on PHP.net for imagettftext produced the same result 
listed here previously = Accents and extended character sets (Polish for 
example) are all missed out or some characters displayed incorrectly 
when --enable-gd-native-ttf is enabled in the PHP compile.

Would be nice to fix this, looks like it's been around a while!
 [2010-06-12 13:22 UTC] f at endeer dot cz
The problem with accents has been reintroduced, but this time it's not --enable-gd-native-ttf, but --enable-gd-jis-conv which is causing this. Verified on PHP 5.2.13.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Apr 28 00:01:28 2024 UTC