php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #26901 Imagettftext(). Some chars prints as square even though they exist in .ttf file
Submitted: 2004-01-14 04:08 UTC Modified: 2004-01-22 18:12 UTC
Votes:8
Avg. Score:4.9 ± 0.3
Reproduced:8 of 8 (100.0%)
Same Version:8 (100.0%)
Same OS:8 (100.0%)
From: jpg at pmers dot net Assigned:
Status: Not a bug Package: GD related
PHP Version: 4.3.4 OS: Linux
Private report: No CVE-ID: None
 [2004-01-14 04:08 UTC] jpg at pmers dot net
Description:
------------
A bug in the imagettftext function.

Some characters is shown as a square as if the char is missing from the fontfile although they are included...

Example of chars are: ? and ? (Czech language)

I have tried to utf8_encode() the string first but the result is still the same.

I have also uploaded the Czech version of tahoma.ttf to the server, the problem still persists


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-01-14 09:17 UTC] iliaa@php.net
Please supply the shortest possible script that can be used 
to replicate the problem and the font file in question. 
 [2004-01-14 09:54 UTC] jpg at pmers dot net
<?php
$im = imagecreate(450,200);
	if ($im=="") { die("Error creating image"); }
$bg_color = imagecolorallocate ($im, 255, 255, 255);
$black = imagecolorallocate($im,0,0,0);

$ttf_tahoma = "[your_path]/ttf/tahoma.ttf"; // edit this

imagettftext($im, 11, 0, 10, 20, $black, $ttf_tahoma, "Example of chars are: ? and ? (Czech language)");

ImagePNG($im);
ImageDestroy($im);
?>
 [2004-01-14 11:08 UTC] jpg at pmers dot net
example output: http://ccres.net/char_test.php
 [2004-01-14 19:48 UTC] iliaa@php.net
Have you tried exporting Czech locale before creating the 
image? 
 [2004-01-15 06:37 UTC] jpg at pmers dot net
I'm not sure if I understand what you mean, I have added the following code:

setlocale(LC_ALL, 'cs_CZ');

Doesn't make any difference.
 [2004-01-16 09:12 UTC] sniper@php.net
Provide the script downloadadble somewhere.

 [2004-01-16 10:20 UTC] moriyoshi@php.net
Some notes about using non-ASCII characters with GD 
extension:

1. Don't enable --enable-gd-jis-conv if you don't really 
understand what you are doing. The option is only 
meaningful when it comes to handling Japanese texts. 
Please refer to the relevant documentation included in 
the GD library distribiton.

2. The FreeType2 library which is used by GD to render a 
bitmap with a given TTF file always assumes the input 
string to be encoded in UTF-8. This means passing 
strings of another encoding (character set) doesn't make 
any sense and it will most likely end up with a bunch of 
square placeholders. Thus you have to encode strings by 
UTF-8 before passing it to ImageTTFText().

3. Make sure that you are using a correct TTF file whose 
glyphs are correctly mapped to the character set by 
which the string you want to rasterlize is represented. 
If it doesn't match, rendering will silently fail.

4. utf8_encode() can only handle the ISO-8859-1 
character set, where the character set that is most 
commonly used in Czech texts is ISO-8859-2. Use 
mb_convert_encoding() or iconv() instead.

 


 
 [2004-01-22 18:12 UTC] moriyoshi@php.net
And this might be helpful too:
http://www.voltex.jp/articles/imagettf_m10n.htm

 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue May 14 15:01:30 2024 UTC