imagefontwidth

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

imagefontwidthGet font width

Descrizione

imagefontwidth(GdFont|int $font): int

Returns the pixel width of a character in font.

Elenco dei parametri

font

Può essere 1, 2, 3, 4, 5 per i font interni con codifica latin2 (dove numeri più alti corrispondono a font più grandi) o qualsiasi identificatore di font registrato con imageloadfont().

Valori restituiti

Returns the pixel width of the font.

Log delle modifiche

Versione Descrizione
8.1.0 The font parameter now accepts both an GdFont instance and an int; previously only int was accepted.

Esempi

Example #1 Using imagefontwidth() on built-in fonts

<?php
echo 'Font width: ' . imagefontwidth(4);
?>

Il precedente esempio visualizzerà qualcosa simile a:

Font width: 8

Example #2 Using imagefontwidth() together with imageloadfont()

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

echo
'Font width: ' . imagefontwidth($font);
?>

Il precedente esempio visualizzerà qualcosa simile a:

Font width: 23

Vedere anche: