imagefontwidth
PHP function
Edit on GitHub ✎
(PHP 4, PHP 5, PHP 7, PHP 8)
Get font width
Description
imagefontwidth(GdFont|int $font): int
Returns the pixel width of a character in font.
Parameters
Return Values
Returns the pixel width of the font.
Changelog
| Version | Description |
|---|
Examples
Using imagefontwidth() on built-in fonts
php
<?php
echo 'Font width: ' . imagefontwidth(4);
?>The above example will output something similar to:
output
Font width: 8Using imagefontwidth() together with imageloadfont()
php
<?php
// Load a .gdf font
$font = imageloadfont('anonymous.gdf');
echo 'Font width: ' . imagefontwidth($font);
?>The above example will output something similar to:
output
Font width: 23