|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2003-05-07 08:52 UTC] nid at home dot se
When installing PHP 4.3.x GD/t1lib stops behave properly. When showing a PS1-type font in an image, some characters get the wrong size.
When downgrading to PHP 4.2.3 the problem went away.
Using the bundled version of GD did not make any difference. Tried with bundled (4.3.x) and GD 2.0.8 (both with 4.3.x and 4.2.x).
The steps I went through are:
1. loading the font with imagepsloadfont('AkzGBS20.pfb');
2. Encoding the font with imagepsencodefont('8859.enc'); (even tried without this)
3. Executed this command: imagepstext($img,$text,$font_1,$size,$fg_color,$bg_color,$x,$y,$space,$tight,$angle,$antialias);
4. Imagepng()
variables:
$size = 12, $space = 0, $angle = 0, $antialias = 16
The code was run with the same source on 4.2.3, 4.3.0 and 4.3.1, and the problem started occuring on 4.3.0.
The font did have access to .afm-file, but it did not make any difference.
The font-file can be located at: http://www.delta-projects.com/AkzGBS20.pfb
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Oct 26 05:00:01 2025 UTC |
Adding some more information along with a code-snippet t1lib version: 1.3.1 Apache version: 1.3.27 The font can be fetched from the location in the main-comment. When running the code, notice that G and Q does render differently from the rest of the characters. ----------[Code starts]------------- $font_1 = imagepsloadfont('./AkzGBS20.pfb'); define('ANTIALIAS_MEDIUM',16); $text = 'abcdefghijklmnopqrstuvxyz'; $x = 15; $size = 12; $y = 0; $space = 0; $tight = 0; $angle = 0; $antialias = ANTIALIAS_MEDIUM; $text = strtoupper($text.''); list($lx,$ly,$rx,$ry) = imagepsbbox($text,$font_1,$size,$space,$tight,$angle); $w = $rx + 30; $h = 18; $y = 12; $img = imagecreate($w,$h); $fg_color = imagecolorallocate($img,133,118,98); $bg_color = imagecolorallocate($img,255,255,255); imagefill($img,2,2,$bg_color); imagepstext($img,$text,$font_1,$size,$fg_color,$bg_color,$x,$y,$space,$tight,$angle,$antialias); imagepng('test.png'); imagedestroy($img); echo '<img src=test.png><br>'; --------------[Code ends]------------I found a solution for this problem, when tampering with ext/gd/gd.c I don't have the original line numbers available, because of some tampering. But it is not hard to find it. In the php-function imagepstext, there is a codesnippet that looks like this: --------[code starts]----- for (i = 1; i < str_len; i++) { amount_kern = (int) T1_GetKerning(*f_ind, str[i-1], str[i]); amount_kern += str[i-1] == ' ' ? space : 0; add_width = (int) (amount_kern+width)/extend; char_path = T1_GetMoveOutline(*f_ind, add_width, 0, 0, size, transform); str_path = T1_ConcatOutlines(str_path, char_path); char_path = T1_GetCharOutline(*f_ind, str[i], size, transform); str_path = T1_ConcatOutlines(str_path, char_path); } str_img = T1_AAFillOutline(str_path, 0); -----[code ends]------- if you instead make this like it WAS in <=php4.2, it should look like this: ----[code starts]---- if (width) // this is the change { for (i = 1; i < str_len; i++) { amount_kern = (int) T1_GetKerning(*f_ind, str[i-1], str[i]); amount_kern += str[i-1] == ' ' ? space : 0; add_width = (int) (amount_kern+width)/extend; char_path = T1_GetMoveOutline(*f_ind, add_width, 0, 0, size, transform); str_path = T1_ConcatOutlines(str_path, char_path); char_path = T1_GetCharOutline(*f_ind, str[i], size, transform); str_path = T1_ConcatOutlines(str_path, char_path); } str_img = T1_AAFillOutline(str_path, 0); } else // change continues here { str_img = T1_AASetString(*f_ind, str, str_len, space, T1_KERNING, size, transform); } ----[code ends]---- Then the problem went away (until you set the space-property to a non-zero value). So, evidentually, there is some kind of bug, or PHP handles spaced texts differently than t1lib does as standard. For further releases, can you _please_ put the "if (width)"-statement as it was before?