imagefontwidth

(PHP 4, PHP 5, PHP 7)
Get font width
int imagefontwidth ( int $font )

Returns the pixel width of a character in font.

Parameters:
font

Can be 1, 2, 3, 4, 5 for built-in fonts in latin2 encoding (where higher numbers corresponding to larger fonts) or any of your own font identifiers registered with imageloadfont().

Returns:

Returns the pixel width of the font.

Examples:
Using imagefontwidth() on built-in fonts
<?php
echo 'Font width: ' . imagefontwidth(4);
?>

The above example will output something similar to:

Font width: 8
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:

Font width: 23
See also:

imagefontheight() -

imageloadfont() -

doc_php
2016-02-24 15:59:47
Comments
Leave a Comment

Please login to continue.