cs.punk Posted April 15, 2010 Share Posted April 15, 2010 Ok with this simple code: <?php header ("Content-type: image/png"); $im = ImageCreate (300, 40); $grey = ImageColorAllocate ($im, 230, 230, 230); $black = ImageColorAllocate ($im, 0, 0, 0); ImageTTFText($im, 20, 0, 10, 25, $black, "arial.ttf", "TrueType Fonts!"); ImagePng ($im); ImageDestroy ($im); ?> It just gives me a non-exsistent image. I am using xampp. Should I load the font first? In which directory? Quote Link to comment https://forums.phpfreaks.com/topic/198645-quick-question-using-ttf-font-with-gd-not-working/ Share on other sites More sharing options...
andrewgauger Posted April 15, 2010 Share Posted April 15, 2010 when fontfile does not begin with a leading / then .ttf will be appended ImageTTFText($im, 20, 0, 10, 25, $black, "arial", "TrueType Fonts!"); Quote Link to comment https://forums.phpfreaks.com/topic/198645-quick-question-using-ttf-font-with-gd-not-working/#findComment-1042513 Share on other sites More sharing options...
teamatomic Posted April 15, 2010 Share Posted April 15, 2010 Try putting the ttf file in the same folder as the script. You may need to use a better reference to the font, like ./arial.ttf HTH Teamatomic Quote Link to comment https://forums.phpfreaks.com/topic/198645-quick-question-using-ttf-font-with-gd-not-working/#findComment-1042537 Share on other sites More sharing options...
cs.punk Posted April 17, 2010 Author Share Posted April 17, 2010 Try putting the ttf file in the same folder as the script. You may need to use a better reference to the font, like ./arial.ttf HTH Teamatomic Thanks! Exactly what I needed! Quote Link to comment https://forums.phpfreaks.com/topic/198645-quick-question-using-ttf-font-with-gd-not-working/#findComment-1043502 Share on other sites More sharing options...
oni-kun Posted April 17, 2010 Share Posted April 17, 2010 Try putting the ttf file in the same folder as the script. You may need to use a better reference to the font, like ./arial.ttf HTH Teamatomic Thanks! Exactly what I needed! If the font is not within GD's predefined library path, it will attempt to search for that filename along a library-defined font path. Note the following example: // Set the enviroment variable for GD putenv('GDFONTPATH=' . realpath('.')); // Name the font to be used (note the lack of the .ttf extension) $font = 'SomeFont'; Otherwise you can do as intended and point the font to the relative path. Quote Link to comment https://forums.phpfreaks.com/topic/198645-quick-question-using-ttf-font-with-gd-not-working/#findComment-1043503 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.