imagefontwidth

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

imagefontwidthGet font width

Опис

imagefontwidth(GdFont|int $font): int

Returns the pixel width of a character in font.

Параметри

font

Може бути 1, 2, 3, 4, 5 для вбудованих шрифтів в кодуванні latin2 (де більші числа відповідають більшим шрифтам) або примірником класу GdFont, що повертається функцією imageloadfont().

Значення, що повертаються

Returns the pixel width of the font.

Журнал змін

Версія Опис
8.1.0 Параметром font тепер може бути як і примірник GdFont, так і int. Раніше допускався тільки int.

Приклади

Приклад #1 Using imagefontwidth() on built-in fonts

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

Поданий вище приклад виведе щось схоже на:

Font width: 8

Приклад #2 Using imagefontwidth() together with imageloadfont()

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

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

Поданий вище приклад виведе щось схоже на:

Font width: 23

Прогляньте також