TrueType font changes size when rotated?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi all! I've been programming GD and PHP for a while, but I haven't
done much with font drawing. I'm trying to layout and draw text, but
the text actually changes size and shape depending on the angle it's
drawn at. This is making it extremely difficult to lay the text out
properly.

Am I doing something wrong? Is there a bug in FreeType? How can I
consistently draw text?

For example:
The following code draws 'Hello world' at differing angles. But all
drawings are at right angles to each other. FreeType shouldn't even
need to do any resampling or interpolating, but each text is drawn
with a unique length and look. You can see the output of the
following code here:
http://leopold.sage.wisc.edu/test2.php


<?php
header('Content-Type:image/png');

$img = imagecreatetruecolor(300, 300);
$bak = imagecolorexact($img, 255,255,255);
imagefill($img, 0,0, $bak);
$col = imagecolorexact($img, 0,0,0);

for($i = 0; $i < 360; $i += 90){
	$b = imageftbbox(12, $i, '/Library/WebServer/Verdana.ttf', 'Hello
world');
	$len = sqrt(($b[2] - $b[0])*($b[2] - $b[0]) + ($b[3] - $b[1])*(($b
[3] - $b[1])));
	imagefttext($img, 12, $i, 150, 150, $col, '/Library/WebServer/
Verdana.ttf', 'Hello world '.$len);
}

imagepng($img);
?>

When using more interesting fonts, this 'resampling' is causing text
drawn at 90 deg to look fugly. What can I do to prevent this? Is this
a known issue? The output doesn't seem to change if I use the 'ttf'
functions vs. the 'ft' functions.

System info:
Mac v10.4 Server running PHP v5.2.1 & FreeType v2.3.4

Compiled with:
'./configure' '--with-apxs' '--with-mysqli=/usr/local/mysql/bin/
mysql_config' '--with-gd' '--with-png-dir=/usr/local' '--with-zlib-
dir=/usr' '--with-jpeg-dir=/usr/local' '--disable-short-tags' '--with-
iconv' '--enable-exif' '--enable-mbstring' '--enable-gd-native-ttf'
'--with-freetype-dir=/usr/local'

Thanks,
Seth

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux