imagefontheight

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

imagefontheight获取字体高度

说明

imagefontheight(GdFont|int $font): int

返回指定字体中字符的像素高度。

参数

font

取值对于内建的 latin2 编码字体可以是:1、2、3、4、5(更高的数字对应更大的字体), 或是通过 imageloadfont() 返回的 GdFont 实例。

返回值

返回字体的像素高度。

更新日志

版本 说明
8.1.0 font 参数现在接受 GdFont 实例和 int,之前仅接受 int

范例

示例 #1 在内置字体上使用 imagefontheight()

<?php
echo 'Font height: ' . imagefontheight(4);
?>

以上例程的输出类似于:

Font height: 16

示例 #2 将 imagefontheight()imageloadfont() 一起使用

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

echo
'Font height: ' . imagefontheight($font);
?>

以上例程的输出类似于:

Font height: 43

参见

add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top