0

Can someone show me a basic imageftbbox function please because im having trouble getting it to work this is what ive tried so far

$bird = imageftbbox( 12, 0, arial.ttf, "Hello World"); print_r($bird);

this gives no output. could someone help?

2 Answers2

0

Add quotes around font file name arial.ttf like below:

$bird = imageftbbox( 12, 0, "arial.ttf", "Hello World");

Below output will come when you correct your code and display with print_r($bird); :-

Array ( [0] => -1 [1] => -1 [2] => 77 [3] => -1 [4] => 77 [5] => -13 [6] => -1 [7] => -13 )

Also make sure arial.ttf font exists in your root folder otherwise you need to give its complete path as described in PHP documentation like below:

enter image description here

Follow below link for more details :-

http://php.net/manual/en/function.imageftbbox.php

Amit Gupta
  • 2,771
  • 2
  • 17
  • 31
  • At the time, it was because you answered a "typo" question by merely pointing it out. Now that you've expanded it with further things to watch out for, I've removed the vote. – Niet the Dark Absol Jan 14 '18 at 14:58
  • @NiettheDarkAbsol Thanks mate! – Amit Gupta Jan 14 '18 at 15:01
  • What if you have a bootstrap font from bootstrap.css. the code still doesnt work for me, im assuming that i dont have the font as a file or something. maybe it doesnt come automatically on macbook airs. – Jevon McPherson Jan 14 '18 at 23:48
  • @JevonMcPherson You have to give the direct path of the font file where it is located. To test it offline, I have download the font arial.ttf from online and located at root folder. You can also do that. You can download from link http://www5.miele.nl/apps/vg/nl/miele/mielea02.nsf/0e87ea0c369c2704c12568ac005c1831/07583f73269e053ac1257274003344e0?OpenDocument – Amit Gupta Jan 15 '18 at 01:20
0

Thank You Amit Gupa your answer was very useful however i was still unable to get the code to work. a quick google search landed me on this page ( imagettftext function using font from remote server ) which helped me finally get the function to work.

    $font = file_get_contents("http://themes.googleusercontent.com/static/fonts/abel/v3/RpUKfqNxoyNe_ka23bzQ2A.ttf");
file_put_contents("font.ttf", $font); //be sure to save the font in the path you have provided as font path.
  $bird = imageftbbox( 12, 0, "font.ttf", "Hello World");
 print_r($bird);