array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'zh', ), 'this' => array ( 0 => 'function.imagefontwidth.php', 1 => 'imagefontwidth', ), 'up' => array ( 0 => 'ref.image.php', 1 => 'GD 和图像处理 函数', ), 'prev' => array ( 0 => 'function.imagefontheight.php', 1 => 'imagefontheight', ), 'next' => array ( 0 => 'function.imageftbbox.php', 1 => 'imageftbbox', ), 'alternatives' => array ( ), 'source' => array ( 'lang' => 'zh', 'path' => 'reference/image/functions/imagefontwidth.xml', ), ); $setup["toc"] = $TOC; $setup["toc_deprecated"] = $TOC_DEPRECATED; $setup["parents"] = $PARENTS; manual_setup($setup); ?>
(PHP 4, PHP 5, PHP 7, PHP 8)
imagefontwidth — 获取字体宽度
返回字体的像素宽度。
示例 #1 在内置字体上使用 imagefontwidth()
<?php
echo 'Font width: ' . imagefontwidth(4);
?>
以上示例的输出类似于:
Font width: 8
示例 #2 将 imagefontwidth() 与 imageloadfont() 一起使用
<?php
// Load a .gdf font
$font = imageloadfont('anonymous.gdf');
echo 'Font width: ' . imagefontwidth($font);
?>
以上示例的输出类似于:
Font width: 23