php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #41878 special characters where not displayed as graphic
Submitted: 2007-07-02 23:23 UTC Modified: 2007-07-11 01:00 UTC
Votes:3
Avg. Score:4.0 ± 1.4
Reproduced:3 of 3 (100.0%)
Same Version:0 (0.0%)
Same OS:2 (66.7%)
From: letters at rmroppert dot de Assigned: pajoye (profile)
Status: No Feedback Package: GD related
PHP Version: 4.4.7 OS: NetBSD (different Versions)
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2007-07-02 23:23 UTC] letters at rmroppert dot de
Description:
------------
 want to put special characters (german umlauts) into an image.
I use imagettftext() and the string "( ? ? ? xx ? ? ? ? ) without blanks ( ???xx???? )".
If i put an blank around the characters it works without blanks there squares.
You see the result on:
http://heisenberg.rmroppert.com/test/gd_php_out.pdf

I tried the same on different machines (i386) under different NETBSD Versions (NetBSD 1.6, NetBSD 3.0.1, NetBSD 3.1)
and different php versions.

You may find the output of phpinfo of our testserver under:
http://heisenberg.rmroppert.com/test/phpinfo1.pdf

I think this is an problem of th built-in version og gd. Perhaps the image is correct if i use perl and gnuplot. 

Reproduce code:
---------------
<?php
$argtext=" ( ? ? ? xx ? ? ? ? ) without blanks ( ??????? ) ";
$font1="/usr/pkg/share/httpd/htdocs/testphp/test/Arial.ttf";
$im = imagecreate (1810, 100);
$white = imagecolorallocate ($im, 255, 255, 255);
$black = imagecolorallocate ($im, 0, 0, 0);
imagefilledrectangle($im,0,0,609,99,$white);
imagettftext ($im, 30, 0, 10, 40, $black, $font1, $argtxt);
header ("Content-type: image/png");
imagejpeg($im);
imagedestroy($im);
?>


Expected result:
----------------
see links in Description



Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-07-03 08:59 UTC] pajoye@php.net
Do you use UTF-8? Text has to be given in UTF-8. If not, it may cause some troubles by the encoding detection or the glyph selection in freetype (esp. when the font only has utf-8).


 [2007-07-03 13:50 UTC] letters at rmroppert dot de
Hello,
thank you for the answer.

I thought it is utf-8, because the function mb_detect_encoding gives utf-8.

After your answer i testet it with
function is_utf8($string) {
   
    // From http://w3.org/International/questions/qa-forms-utf-8.html
    return preg_match('%^(?:
          [\x09\x0A\x0D\x20-\x7E]            # ASCII
        | [\xC2-\xDF][\x80-\xBF]             # non-overlong 2-byte
        |  \xE0[\xA0-\xBF][\x80-\xBF]        # excluding overlongs
        | [\xE1-\xEC\xEE\xEF][\x80-\xBF]{2}  # straight 3-byte
        |  \xED[\x80-\x9F][\x80-\xBF]        # excluding surrogates
        |  \xF0[\x90-\xBF][\x80-\xBF]{2}     # planes 1-3
        | [\xF1-\xF3][\x80-\xBF]{3}          # planes 4-15
        |  \xF4[\x80-\x8F][\x80-\xBF]{2}     # plane 16
    )*$%xs', $string);
   
}

and this gives 0, also not utf-8. :-(

I quickly made this test:
I use char("???") it gives 228 which is correct ISO... "?",
then utf8_encode("???") and testing with the function is_utf8 gives 1, also the string seems now to be utf-8 encoded.
If i now send this converted string to "imagettftext" the result is
again one square and ?.
Possibly i made something wrong, because i am not an php programmer.  
But for me it seems, that the code of two characters become one utf-8 character. 

I am making more tests next days an then i tell the results.
If someone can tell some futher tests, i will do them an post the results.
 [2007-07-11 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon May 13 20:01:34 2024 UTC