imagefontwidth()函數是PHP中的內置函數,用於獲取指定字體中字符的像素寬度。
用法:
int imagefontwidth( int $font )
參數:該函數接受一個包含字體的單個參數$font。對於內置字體,它可以是1、2、3、4、5。對於自定義字體,它可以與imageloadfont()一起使用。
返回值:此函數返回一個包含字體寬度的整數值。
以下示例程序旨在說明PHP中的imagefontwidth()函數:
程序1:
<?php
// Get the font width
echo 'Font width for font value 1 is '
. imagefontwidth(1) . '<br>';
echo 'Font width for font value 2 is '
. imagefontwidth(2) . '<br>';
echo 'Font width for font value 3 is '
. imagefontwidth(3) . '<br>';
echo 'Font width for font value 4 is '
. imagefontwidth(4) . '<br>';
echo 'Font width for font value 5 is '
. imagefontwidth(5) . '<br>';
?>
輸出:
Font width for font value 1 is 5 Font width for font value 2 is 6 Font width for font value 3 is 7 Font width for font value 4 is 8 Font width for font value 5 is 9
程序2:
<?php
// Get the font from local folder
$font = imageloadfont('Pacifico.ttf');
// Show the output
echo 'Font width for Pacifico is '
. imagefontwidth($font);
?>
輸出:
Font width for Pacifico is 5
參考: https://www.php.net/manual/en/function.imagefontwidth.php
相關用法
- CSS url()用法及代碼示例
- PHP next()用法及代碼示例
- p5.js pow()用法及代碼示例
- PHP each()用法及代碼示例
- p5.js second()用法及代碼示例
- p5.js day()用法及代碼示例
- PHP pow( )用法及代碼示例
- d3.js d3.map.set()用法及代碼示例
- CSS var()用法及代碼示例
- p5.js hue()用法及代碼示例
- p5.js value()用法及代碼示例
- p5.js hex()用法及代碼示例
注:本文由純淨天空篩選整理自gurrrung大神的英文原創作品 PHP | imagefontwidth() Function。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。