开发者

Can I programmatically determine what fonts I can use with GD?

I want to put text over an image using GD.

When I use

ImageTTFText($image, $fontSize, $fontRotation, 7, 22, $colorShadow, 'arial.ttf', $str);

I get

Warning: imagettftext() [function.imagettftext]: Could not find/open font in /home/index.php on line开发者_JS百科 17

Can I get PHP or GD to return a list of all available fonts per my system?

Thanks

Update

... or do I need to upload myself all the fonts myself that I wish GD to have access to?


Replace "arial.ttf" with "./arial.ttf", because "arial.ttf" is an absolute path and you need a relative path. Read more on imagettftext here.

To answer your update, yes, you do need the font files in that directory. Here is a really cool site for finding fonts (like arial.ttf): http://www.1001freefonts.com/

Download a font file from there, put it in the folder of your script, and then replace "arial.ttf" with "./filename.ttf".


If you can use Imagemagick there is always that


The fonts can be anywhere,but you must specify the full path to arial.ttf.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜