Reputation: 12015
<?php
$size = 12;//font height
$font = 'Arial';// your font
$char = 'Test';
$char = 'With W';
$char = 'without w but with p and y and q';
$rect = imagettfbbox($size, 0, $font, $char);
$image_height =abs( $rect[7] );//do no respect bottom margin
$imw = $rect[2] - $rect[0]; //as usual
$bx = abs( $rect[ 0 ] ); // X offset
$by = $size * 1.25; // Y offset - we will use const LINEHEIGHT
?>
Can you help me with this error?
Warning: imagettfbbox() [function.imagettfbbox]: Invalid font filename in C:\wamp\www\test\createImage.php on line 8
Upvotes: 0
Views: 8212
Reputation: 1
It worked for me when using:
$font = './arial.ttf';
after I copied the arial file from
"(C:/Windows/)fonts
" to the directoty in which the php file resides.
Upvotes: 0
Reputation: 18440
The font argument should be a .ttf file, not a font name. You can find a lot of resources for fonts with a quick google search.
https://secure.php.net/manual/en/function.imagettfbbox.php
Upvotes: 2
Reputation: 1
Beware of path. If you use pChart the examples work, but your file doesn't work because the path of font files.
Therefore you must replace ../
with blank.
Example: ../fonts/Forgotte.ttf
with fonts/Forgotte.ttf
. For me it works
Upvotes: -1