
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Get Pixel Height of Character in Specified Font using 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
Advertisements