PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
It works on my own server, but when I test it at ByetHost it does not work. It only outputs a red image without the text. For some reason the text is not outputted into the image. I asked support from ByetHost but they just keep saying the function imagettftext() works well.
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Umm,
This is the code:
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
1. You're uploading it to a UNIX/Linux server. Unix OSs are case sensitive ... "tahoma.ttf" is not the same as "Tahoma.ttf" or "tahoma.TTF" or "TAHOMA.TTF". Solution: Make the filename in the code exactly the same as the one on the server.
2. The file isn't in GD's font path. Bizarrely, some installs of PHP hide the current directory from GD. Solution: Stick "putenv('GDFONTPATH=' . realpath('.'));" at the top of the script, or refer to the font as "./tahoma.ttf".
3. PHP isn't running the script from the same location as the script resides. Solution: Check getcwd() and potentially change the path to the font.
4. Your "tahoma.ttf" file is a bit whack. PHP can't use all TTF font files because some are different to others. There's a free program called FontWizard (or something like that) that can fix them.
Just a nudge, make sure you you have the freetype library installed with GD, else you are stuck with lousy GD fonts and you can not use tt fonts. As was my case so I had to make CAPTCHA images without one. I would check to make sure. Sorry if you already know this.
jyhm wrote:Just a nudge, make sure you you have the freetype library installed with GD, else you are stuck with lousy GD fonts and you can not use tt fonts. As was my case so I had to make CAPTCHA images without one. I would check to make sure. Sorry if you already know this.
The first post in the thread wrote:I asked support from ByetHost but they just keep saying the function imagettftext() works well.
Assuming the support people aren't lying then we can take it as given that the function works.