Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

PHP | imagefontheight() Function

  • Last Updated : 14 Feb, 2020

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 built-in fonts or can be used with imageloadfont() for custom fonts.

Return Value: This function returns an integer value containing the height.

Below given programs illustrate the imagefontheight() function in PHP:



Program 1:




<?php
  
// Get the font height
echo 'Font height for font value 1 is '
        . imagefontheight(0) . '<br>';
  
echo 'Font height for font value 2 is '
        . imagefontheight(2) . '<br>';
  
echo 'Font height for font value 3 is '
        . imagefontheight(3) . '<br>';
  
echo 'Font height for font value 4 is '
        . imagefontheight(4) . '<br>';
  
echo 'Font height for font value 5 is '
        . imagefontheight(5) . '<br>';
?>

Output:

Font height for font value 1 is 8
Font height for font value 2 is 13
Font height for font value 3 is 13
Font height for font value 4 is 16
Font height for font value 5 is 15

Program 2:




<?php
  
// Get the font from local folder
$font = imageloadfont('Pacifico.ttf');
  
// Show the output
echo 'Font height for Pacifico is '
         . imagefontheight($font);
?>

Output:

Font height for Pacifico is 8

Reference: https://www.php.net/manual/en/function.imagefontheight.php




My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!