1

The PHP manual page for imagettfbbox says:

fontfile The name of the TrueType font file (can be a URL)

but passing a URL gives a Unable to access error.

I have a number of fonts on my Amazon S3 account, like http://bililite.s3.amazonaws.com/webservices/fonts/Lilly.ttf and I'd like to use them on a webpage, with

$box = imagettfbbox (12, 0,
  'http://bililite.s3.amazonaws.com/webservices/fonts/Lilly.ttf', 'Hello, World');

But I just get the error. I've tried it on two different servers with two different providers, and other URL's besides S3 and get the same error. The URL is valid; I can download the font. allow_url_fopen is set. Is the manual wrong about using URL's? If I'm stuck, I can curl the font URL into a temporary file and use that, but I'd rather not.

  • At first, try to use a local font. – yunzen Feb 29 '12 at 12:16
  • Local fonts work fine. Grabbing the font file with `file_get_contents` and saving it to a temporary file, then `unlink`ing it when I'm done works fine. I'm trying to avoid storing huge files on my website, especially multiple ones. – DANIEL WACHSSTOCK Feb 29 '12 at 21:04
  • Do you think a font file is huge? – yunzen Mar 01 '12 at 08:52
  • Perhaps because the font at this address is delivered with the HTTP header application/octet-stream? – yunzen Mar 01 '12 at 08:57
  • @yunzen:I'm using nearlyfreespeech.net and they base all their charges on storage; it's much cheaper to put big files on S3. Also, the appropriate MIME-type for ttf fonts is application/octet-stream ([http://stackoverflow.com/questions/5128069/ttf-mime-type]). Do you know of a better one? – DANIEL WACHSSTOCK Mar 04 '12 at 16:27

0 Answers0