PHP | imagefontwidth() Function Last Updated : 14 Feb, 2020 Comments Improve Suggest changes Like Article Like Report 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 can be used with imageloadfont() for custom fonts. Return Value: This function returns an integer value containing the font width. Below programs illustrate the imagefontwidth() function in PHP: Program 1: php <?php // Get the font width echo 'Font width for font value 1 is ' . imagefontwidth(1) . '<br>'; echo 'Font width for font value 2 is ' . imagefontwidth(2) . '<br>'; echo 'Font width for font value 3 is ' . imagefontwidth(3) . '<br>'; echo 'Font width for font value 4 is ' . imagefontwidth(4) . '<br>'; echo 'Font width for font value 5 is ' . imagefontwidth(5) . '<br>'; ?> Output: Font width for font value 1 is 5 Font width for font value 2 is 6 Font width for font value 3 is 7 Font width for font value 4 is 8 Font width for font value 5 is 9 Program 2: php <?php // Get the font from local folder $font = imageloadfont('Pacifico.ttf'); // Show the output echo 'Font width for Pacifico is ' . imagefontwidth($font); ?> Output: Font width for Pacifico is 5 Reference: https://www.php.net/manual/en/function.imagefontwidth.php Comment More infoAdvertise with us Next Article PHP | imagepng() Function G gurrrung Follow Improve Article Tags : Web Technologies PHP PHP-function PHP-image-functions Similar Reads 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 | imageloadfont() Function 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 functi 2 min read PHP | imagefttext() Function The imagefttext() function is an inbuilt function in PHP which is used write text to the image using fonts using FreeType 2. Syntax: array imagefttext( resource $image, float $size, float $angle, int $x, int $y, int $color, string $fontfile, string $text, array $extrainfo ) Parameters: This function 2 min read PHP | imagettftext() Function The imagettftext() function is an inbuilt function in PHP which is used to write text to the image using TrueType fonts. Syntax: array imagettftext( resource $image, float $size, float $angle, int $x, int $y, int $color, string $fontfile, string $text) Parameters: This function accept eight paramete 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 | imagechar() Function The imagechar() function is an inbuilt function in PHP which is used to draw a character horizontally. This function draws the first character of string in the image identified by image with its x and y-axis. The coordinate of the top-left corner is (0, 0). Syntax: bool imagechar( $image, $font, $x, 2 min read Like