PHP | imageloadfont() Function Last Updated : 14 Feb, 2020 Summarize Comments Improve Suggest changes Share Like Article Like Report The imageloadfont() function is an inbuilt function in PHP which is used to load a new font. GDF fonts are supported which can be downloaded from here. Syntax: int imageloadfont( string $file ) Parameters: This function accepts a single parameter $file which holds the font. Return Value: This function returns font identifier which is always bigger than 5 to avoid conflicts with built-in fonts or FALSE on errors. Below given programs illustrate the imageloadfont() function in PHP: Program 1 (Writing on a drawing): php <?php // Create a new image instance $im = imagecreatetruecolor(105, 15); // Prepare the colors $black = imagecolorallocate($im, 0, 0, 0); $white = imagecolorallocate($im, 255, 255, 255); // Make the background white imagefilledrectangle($im, 0, 0, 700, 250, $white); // Load the gd font from local folder // and write 'GeeksforGeeks' $font = imageloadfont('./Hollow_8x16_LE.gdf'); imagestring($im, $font, 0, 0, 'GeeksforGeeks', $black); // Scale the image bigger $im1 = imagescale($im, 700); // Output to browser header('Content-type: image/png'); imagepng($im1); imagedestroy($im); ?> Output: Program 2 (Writing on an image): php <?php // Create an image instance $im = imagecreatefrompng( 'https://media.geeksforgeeks.org/wp-content/uploads/geeksforgeeks-13.png'); // Prepare the red color $red = imagecolorallocate($im, 255, 0, 0); // Load the gd font from local folder and write 'GeeksforGeeks' $font = imageloadfont('./Hollow_8x16_LE.gdf'); imagestring($im, $font, 200, 100, 'GeeksforGeeks', $red); // Output to browser header('Content-type: image/png'); imagepng($im); imagedestroy($im); ?> Output: Reference: https://www.php.net/manual/en/function.imageloadfont.php Comment More infoAdvertise with us Next Article PHP | imagefontheight() Function G gurrrung Follow Improve Article Tags : Web Technologies PHP PHP-function PHP-image-functions Similar Reads PHP | imagefontwidth() Function The imagefontwidth() function is an inbuilt function in PHP which is used to get the pixel width of a character in the specified font. Syntax: int imagefontwidth( int $font ) Parameters: This function accept a single parameter $font which holds the font. It can be 1, 2, 3, 4, 5 for built-in fonts or 2 min read PHP | imagegd() function The imagegd() function is an inbuilt function in PHP which is used to output GD image to browser or file. This is most useful to convert any other image type to gd. imagecreatefromgd() function can be used to further read gd images. Syntax: bool imagegd( resource $image, float $to) Parameters:This 2 min read PHP | imagepng() Function The imagepng() function is an inbuilt function in PHP which is used to display image to browser or file. The main use of this function is to view an image in the browser, convert any other image type to PNG and applying filters to the image. Syntax: bool imagepng( resource $image, int $to, int $qual 2 min read PHP | imagefontheight() Function The imagefontheight() function is an inbuilt function in PHP which is used to get the pixel height of a character in the specified font. Syntax: int imagefontheight( int $font ) Parameters:This function accepts a single parameter $font which holds the font value. Its value can be 1, 2, 3, 4, 5 for b 2 min read PHP | imagegif() Function The imagegif() function is an inbuilt function in PHP which is used to create the GIF image file from the given image. If the image has been made transparent with imagecolortransparent() function, then GIF89a image format will generate otherwise GIF87a image format will generate. Syntax: bool imageg 2 min read PHP | imagegd2() Function The imagegd2() function is an inbuilt function in PHP which is used to output GD2 image to browser or file. This is most useful to convert any other image type to gd2. The imagecreatefromgd2() function can be used to further read gd2 images. Syntax: bool imagegd2( resource $image, float $to, int $ch 2 min read Like