php width,PHP imagefontwidth()用法及代码示例

imagefontwidth()函数是PHP中的内置函数,用于获取指定字体中字符的像素宽度。

用法:

int imagefontwidth( int $font )

参数:该函数接受一个包含字体的单个参数$font。对于内置字体,它可以是1、2、3、4、5。对于自定义字体,它可以与imageloadfont()一起使用。

返回值:此函数返回一个包含字体宽度的整数值。

以下示例程序旨在说明PHP中的imagefontwidth()函数:

程序1:

// Get the font width

echo 'Font width for font value 1 is '

. imagefontwidth(1) . '
';

echo 'Font width for font value 2 is '

. imagefontwidth(2) . '
';

echo 'Font width for font value 3 is '

. imagefontwidth(3) . '
';

echo 'Font width for font value 4 is '

. imagefontwidth(4) . '
';

echo 'Font width for font value 5 is '

. imagefontwidth(5) . '
';

?>

输出:

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:

// 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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值