View Full Version : TrueType Fonts In PHP Images
digitalpoint
Mar 13th 2004, 11:28 am
I decided to change the font used in the image generation for the keyword tracker charts from the default font to a Unicode TTF font. This would allow people tracking keywords in multi-byte languages to show their keywords within the legend properly (for Japanese, Chinese, Russian, etc. keywords).
But I ran into an interesting bug... When you apply a string to the image with the imagettftext() function, the color of the font is always an ugly yellow, regardless of the color specified. It turns out that this is only a problem when the image itself is a true color image that was created with the imagecreatetruecolor() function. If you instead use imagecreate(), the font colors work as expected.
The problem for me is the true color imaging is what allows for anti-aliased lines within the chart, and the alpha blending transparency of the legend. I'm curious if anyone has run into this problem before and if there is any "simple" work-around? I'm using the latest version of PHP (4.3.4), but I did notice in the development logs that the upcoming PHP 4.3.5 has newer GD libs built into it. So I'm crossing my fingers that it's just a GD Lib problem, and maybe it will magically go away with the update.
- Shawn
nlopes
Mar 14th 2004, 4:18 am
You may already install a snapshot of PHP 4.3.5.
There are very few new features in PHP 4.3.5. This release will be only a bug release before PHP 5.
PHP 5 will still take more 2 moths to become stable (at least).
Grab a snapshot from http://snaps.php.net and test if it works.
If not, open a bug in http://bugs.php.net and then I may help you (i'm a php developper!)
digitalpoint
Mar 14th 2004, 8:51 am
Well I'm not in that much of a hurry... 4.3.5 is almost released, so I'll try it when it's out and let you know. :)
- Shawn
nlopes
Mar 14th 2004, 9:23 am
PHP 4.3.5 is in version RC2. I think it is going only to be released when PHP 5 cames out.
It has no bugs, since in last months the PHP team has been only correcting bugs on it and NOT adding new features.
ikkiphenix
Mar 26th 2004, 5:15 pm
At last someone who experienced the same bug as me: these ugly yellow fonts with imagecreatetruecolor() !
I reported the bug: http://bugs.php.net/bug.php?id=27693
I'm just hoping the latest PHP-version 4.3.5 (released out today) really fixes the bug as said in the answer, and my hoster intends to migrate...
As soon as soon as someone has tried PHP4.3.5, let us know ;-)
Have a nice day.
digitalpoint
Mar 26th 2004, 5:18 pm
Yeah... would be nice for me if it worked. I didn't get *too* much into it though to determine if it's the gd lib or PHP itself. I'm assuming it's a gd lib problems, which is why I was hopeful 4.3.5 will fix it (since it updated the bundled gd lib).
- Shawn
digitalpoint
Mar 30th 2004, 12:53 pm
Just as a FYI, I installed PHP 4.3.5 today, and still the same problem. :(
- Shawn
nlopes
Apr 3rd 2004, 6:58 am
I've the provided script in the bug report with PHP 4.2.6RC2-dev (snapshot from http://snaps.php.net) and everything works fine.
I've tested with a couple of fonts.
Can you please test the script with different fonts with a fresh snapshot, please?
If it doesn't work, send me the font you are using or contact Ilia throught the bug report (he is the best bug hunter and developper of the GD extension).
digitalpoint
Apr 3rd 2004, 9:16 am
I'll test it again when 4.3.6 is released (final). Don't particularly want to install RC stuff on the production machine.
- Shawn
nlopes
Apr 3rd 2004, 10:49 am
As I have told you before, PHP 4 is higly stable.
Using a release version or a snapshot is merely numbers. If you follow the php internalls mailling list you'll note that.
So I think you may always use the latest stable snapshot (4.3.6-dev) because you'll benefith from some bug fixes.
There is a feature frozen a long time ago. The adittions now are just bug fixing and they are really stable.
digitalpoint
Apr 3rd 2004, 10:59 am
Well I'm not in any big rush... It's not a feature I *have* to have... it would just be nice being able to use TTF within true color images.
- Shawn
nlopes
Apr 9th 2004, 9:01 am
Derick, also a very good programmer as marked the bug report as bogus.
Try to compile PHP with the latest freetype 2 library and it should work with no problems.
techwizz78
Aug 18th 2007, 5:59 pm
Im also having a php font issue.
Can't seem to assign the font via a variable?
Anyone else have this issue? The text yeah... the font no.
sea otter
Aug 18th 2007, 10:17 pm
Holy crap, way to resurrect a three year old thread.
Anyhow...what exactly do you mean? It would help if you posted the non-working code fragment.
vBulletin® v3.6.8, Copyright ©2000-2008, Jelsoft Enterprises Ltd.