
- PHP 7 Tutorial
- PHP 7 - Home
- PHP 7 - Introduction
- PHP 7 - Performance
- PHP 7 - Environment Setup
- PHP 7 - Scalar Type Declarations
- PHP 7 - Return Type Declarations
- PHP 7 - Null Coalescing Operator
- PHP 7 - Spaceship Operator
- PHP 7 - Constant Arrays
- PHP 7 - Anonymous Classes
- PHP 7 - Closure::call()
- PHP 7 - Filtered unserialize()
- PHP 7 - IntlChar
- PHP 7 - CSPRNG
- PHP 7 - Expectations
- PHP 7 - use Statement
- PHP 7 - Error Handling
- PHP 7 - Integer Division
- PHP 7 - Session Options
- PHP 7 - Deprecated Features
- PHP 7 - Removed Extensions & SAPIs
- PHP 7 Useful Resources
- PHP 7 - Quick Guide
- PHP 7 - Useful Resources
- PHP 7 - Discussion
How to get the pixel height of a character in the specified font using the imagefontheight() function in PHP?
imagefontheight() is an inbuilt function in PHP that is used to get the pixel height of a character in the specified font.
Syntax
int imagefontheight(int $font)
Parameters
imagefontheight() takes one parameter, $font. It holds the font value. The $font values can be 1, 2, 3, 4, and 5 for the built-in fonts or it can be used by using imageloadfont() function for custom fonts.
Return Values
imagefontheight() returns the pixel height of the font.
Example 1
<?php // font height values can be change from 1 to 5. echo 'Font height: ' . imagefontheight(3); ?>
Output
Font height: 13
Example 2
<?php // Get the font height from 1 to 5 echo 'Font height for the font value 1 is' .imagefontheight(1) .'<br>'; //<br> is used for the line break echo 'Font height for the font value 2 is' .imagefontheight(2) . '<br>'; echo 'Font height for the font value 3 is' .imagefontheight(3) . '<br>'; echo 'Font height for the font value 4 is' .imagefontheight(4) .'<br>'; echo 'Font height for the font value 5 is ' .imagefontheight(5) .'<br>'; ?>
Output
Font height for the font value 1 is 8 Font height for the font value 2 is 13 Font height for the font value 3 is 13 Font height for the font value 4 is 16 Font height for the font value 5 is 15
- Related Articles
- How to get the pixel width of a character in the specified font using the imagefontwidth() function in PHP?
- How to set a single pixel using imagesetpixel() function in PHP?
- How to get the current character font size in IText using FabricJS?
- PHP – How to get the substitution character using mb_substitute_character()?
- How to get the value of a specific pixel in OpenCV using C++?
- How to get the clipping rectangle using imagegetclip() function in PHP?
- PHP – How to get the Unicode point value of a given character?
- How to get a part of string after a specified character in JavaScript?
- How to get or set the resolution of an image using imageresolution() function in PHP?
- How to get the pixel depth and color depth of a screen in JavaScript?
- How to compute the height of a character at given position in Text using FabricJS?
- PHP – How to return the character count of a string using iconv_strlen()?
- How to get the height of a div element using jQuery?
- PHP – How to get the modulus of an arbitrary precision number using bcmod() function?
- How to get the ActionBar height in Android using Kotlin?

Advertisements