php8.5
Home/ Manual/ image / functions/ imagefontheight

imagefontheight

PHP function Edit on GitHub ✎

(PHP 4, PHP 5, PHP 7, PHP 8)

Get font height

Description

imagefontheight(GdFont|int $font): int

Returns the pixel height of a character in the specified font.

Parameters

Return Values

Returns the pixel height of the font.

Changelog

VersionDescription

Examples

Using imagefontheight() on built-in fonts

php
<?php
echo 'Font height: ' . imagefontheight(4);
?>

The above example will output something similar to:

output
Font height: 16

Using imagefontheight() together with imageloadfont()

php
<?php
// Load a .gdf font
$font = imageloadfont('anonymous.gdf');

echo 'Font height: ' . imagefontheight($font);
?>

The above example will output something similar to:

output
Font height: 43

See Also

Source: reference/image/functions/imagefontheight.xml · from the official PHP manual (php/doc-en)