php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #37009 I got wrong letter ? and ? !
Submitted: 2006-04-07 15:13 UTC Modified: 2007-08-20 10:46 UTC
Votes:3
Avg. Score:4.3 ± 0.5
Reproduced:3 of 3 (100.0%)
Same Version:1 (33.3%)
Same OS:2 (66.7%)
From: bengt at sm7jqb dot se Assigned:
Status: Closed Package: Documentation problem
PHP Version: 4.4.1 OS: RedHat Linux 7.3
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: bengt at sm7jqb dot se
New email:
PHP Version: OS:

 

 [2006-04-07 15:13 UTC] bengt at sm7jqb dot se
Description:
------------
This line prtoduse vrong letter '?' and '?' !
<br />
<img src="http://sm7jqb.se/PHP/knappjpeg.php?bild=knapp&text=Test-???-???&font=3&height=20">	*.jpeg

Is that bug fixed in the new 4.4.2 ?


Reproduce code:
---------------
<?php
header("Content-type: image/jpeg");
$text = $_GET['text'];
$bild = $_GET['bild'];
if ( !$_GET['font'] ) $font = 3; else $font = $_GET['font'];

$bgimg = imagecreatefromjpeg("./bild/".$bild.".jpg");
if ( !$_GET['height'] ) 
	$height = imagesy($bgimg); else $height = $_GET['height'];

//	G?r en lagom stor ny bild
if ( $width < ((strlen($text)*9.0)+11)) 
	$width = (strlen($text)*9.0)+11;

$im = imagecreate($width, $height);
$bgc = imagecolorallocate($im, 255, 255, 200);
$black = imagecolorallocate($im, 0, 0, 0);
$grey = imagecolorallocate($im, 100, 100, 100);
$ltgrey = imagecolorallocate($im, 250, 250, 250);

imagefill($im,0,0,$bgc);


//	V?nster del
$dst_x = 0;
$dst_y = 0;
$src_x = 0;
$src_y = 0;
if ( imagesx($bgimg) < ((int)imagesx($im)/2+0.9) )	$src_w = ((int)imagesx($bgimg)/2+0.9);	else	
$src_w = ((int)imagesx($im)/2+0.9);
$src_h = imagesy($im);
imageCopyMerge($im, $bgimg, $dst_x, $dst_y, $src_x, $src_y, $src_w, $src_h, 100);

$dst_x = $src_w;
$src_x = imagesx($bgimg)-$src_w;

while ( ($dst_x+$src_w) < (imagesx($im)-$src_w) ) {
	$src_x = 1;
imageCopyMerge($im, $bgimg, $dst_x, $dst_y, $src_x, $src_y, $src_w, $src_h, 100);
	$dst_x += $src_w-1;
	}

//	H?ger del
if ( imagesx($bgimg) < ((int)imagesx($im)/2+0.9) ) {
	$src_w = imagesx($bgimg);	
	$src_x = 1;	
	}
	else 
	$src_w = ((int)imagesx($im)/2+1.9);
$dst_x = imagesx($im) - $src_w + 1;
imageCopyMerge($im, $bgimg, $dst_x, $dst_y, $src_x, $src_y, $src_w, $src_h, 100);


//	L?gg p? texten
$px    = (imagesx($im) - 7.0 * strlen($text)) / 2;
$py	   = (imagesy($im) - 13.0) / 2;

if ( $_GET['shadow'] == 'grey' ) 
	imagestring($im, $font, $px+2, $py+2, $text, $grey);
if ( $_GET['shadow'] == 'ltgrey' ) 
	imagestring($im, $font, $px+2, $py+2, $text, $ltgrey);
imagestring($im, $font, $px, $py, $text, $black);
imagejpeg($im);
imagedestroy($im);
imagedestroy($bgimg);
?> 


Expected result:
----------------
I vant the text on my button but I got wrong letter '?' and '?'

Try it!


Actual result:
--------------
You can run the script your self to se

http://www.sm7jqb.se/PHP/knappjpeg.php?bild=knapp&text=Test-???-???&font=3&height=20

Thanks!

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-04-07 15:25 UTC] tony2001@php.net
Not enough information was provided for us to be able
to handle this bug. Please re-read the instructions at
http://bugs.php.net/how-to-report.php

If you can provide more information, feel free to add it
to this bug and change the status back to "Open".

Thank you for your interest in PHP.



 [2006-04-07 16:27 UTC] bengt at sm7jqb dot se
Hi,

It is basicly this line doing wrong

imagestring($im, $font, $px, $py, $text, $black);

And I think it is something wrong in the 'font' data !
You can se it here http://sm7jqb.se/PHP/
It is ?L  it shuld be an ?
The text on that button shuld be "Test-???-???"
 [2006-04-07 16:49 UTC] pajoye@php.net
Can you provide a 3-5lines script to reproduce your problem?

A static string, imagestring, imagepng, that's all.

 [2006-04-08 00:41 UTC] derick@php.net
The built in fonts in GD all use latin2 which doesn't have your characters in the same places as the latin1 you're using. ..
 [2006-04-08 05:24 UTC] bengt at sm7jqb dot se
My eample is here http://sm7jqb.se/PHP/test_sv_jpeg.php

And the script, just taken from the book
<?php
$im = imagecreate(150, 30);
$bg = imagecolorallocate($im, 250, 250, 250);
$textcolor = imagecolorallocate($im, 0, 0, 0);

// write the string at the top left
imagestring($im, 5, 0, 0, "-Test-???-???-", $textcolor);
//My swedish letter ?-? goes wrong, just this letter only!

// output the image
header("Content-type: image/jpeg");
imagejpeg($im);
?> 

My webhotel run 4.4.1 byt I have same truble at home with 4.1. and it was the same problem with 4.0
 [2006-04-08 10:56 UTC] pajoye@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

You have to give latin2 (ISO-8859-2) strings or char.
 [2006-04-08 11:59 UTC] derick@php.net
This is not mentioned in the documentation, and another problem is that latin2 doesn't have the swedish characters. I think you can use UTF8 but that should be verified.
 [2006-04-08 12:00 UTC] bengt at sm7jqb dot se
Hi,

In Swedish we use these 3 extra letters ??? and ? is missing :(
 [2006-04-08 12:06 UTC] pajoye@php.net
bengt: Use a truetype font

Derick is right, it should be documented.
 [2007-08-20 10:46 UTC] vrana@php.net
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.

Thank you for the report, and for helping us make our documentation better.

"Can be 1, 2, 3, 4, 5 for built-in fonts in latin2 encoding"
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Jun 02 08:01:31 2024 UTC