Can be 1, 2, 3, 4, 5 for built-in
fonts in latin2 encoding (where higher numbers corresponding to larger fonts) or GdFont instance,
returned by imageloadfont.
Return Values
Returns the pixel width of the font.
Changelog
Version
Description
8.1.0
The font parameter now accepts both an GdFont instance
and an int; previously only int was accepted.
Examples
Example #1 Using imagefontwidth on built-in fonts
<?php
echo 'Font width: ' . imagefontwidth(4);
?>
The above example will output
something similar to:
Font width: 8
Example #2 Using imagefontwidth together with imageloadfont
<?php
// Load a .gdf font
$font = imageloadfont('anonymous.gdf');
echo 'Font width: ' . imagefontwidth($font);
?>
The above example will output
something similar to: