Re: TrueType font changes size when rotated? (the plot thickens)

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

 



On 4/25/07, Seth Price <sprice@xxxxxxxx> wrote:
So I've rewritten my script in C. You can find the source here:
http://leopold.sage.wisc.edu/testing/gd_ft_ang.c

This script links directly to GD and produces a still different
output. On my home system, the output image is correct and the length
89 px. On the web server, the output image is not correct, but a bit
more consistent than the output from PHP. You can see it here:
http://leopold.sage.wisc.edu/testing/gd35_ft15.3.png

What is the difference between my home system and the web server? The
web server is running the most current versions, but my home system
is not. So, that's odd. Could some of you with GD and FreeType
installed take a look at my source code and see if my output image
matches yours?

To help eliminate variables, you can download a copy of the font file
I'm using here:
http://leopold.sage.wisc.edu/testing/Verdana.ttf

It sounds like this may be a bug in GD or FreeType.
Thanks,
Seth

I have freetype-2.2.1 & gd-2.0-RC2 (and GCC-4.0.3)

I've compiled your C code with:
gcc -o gd_ft_ang gd_ft_ang.c
(I've modified the source to match the path of your font)
and then i ran ./gd_ft_ang

It gives me this image:
http://img175.imageshack.us/img175/8407/testvm6.png

I hope this helps you

Tijnema



On Apr 25, 2007, at 12:29 AM, jekillen wrote:

>
> On Apr 24, 2007, at 8:26 PM, Seth Price wrote:
>
>> 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/
> you're using Mac OSX, did you have to install gd or does it now
> come with
> gd included in the php installation? (after looking further down
> the message,
> I see you are running Server, so that is probably the difference)
> Mine did not (OSX 1.4x). I have it installed on a FreeBSD system.
> www.brushandbard.com -> web design -> dynamic image generation
> demonstration
> and Word Wise the Tile Puzzle are some of my projects using gd.
>> 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.
> I went looking for some samples, as I have played with this some in
> the
> past, but did not find anything current to show. I do not remember
> having
> this problem. There may be a distortion that is being entered into
> the mix
> when the fonts are rendered by your code. $len is the hypoteneus of a
> right triangle, right off hand I would say that is your problem or
> some of it.
> The length should be a linear measurement and not a diagonal
> measurement.
> But I am rusty at this point. Also there is a function for
> explicitly specifying
> the angle of the font in degrees, and, as I remember the angle of the
> rendering box also. This is so each font can be rendered at an
> individual
> angle and the whole enclosing box, so the whole word is rotated.
>  you will have to look in the manual for gd related functions if
> you are
> not aware of this.
> Jeff K
>
>> 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
>>
>

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



--
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