imageloadfont()函数是PHP中的内置函数,用于加载新字体。支持GDF字体,可以从此处下载。
用法:
int imageloadfont( string $file )
参数:该函数接受一个包含字体的单个参数$file。
返回值:此函数返回的字体标识符始终大于5,以避免与内置字体或错误时为FALSE冲突。
下面给出的程序说明了PHP中的imageloadfont()函数:
程序1(在图纸上书写):
<?php
// Create a new image instance
$im = imagecreatetruecolor(105, 15);
// Prepare the colors
$black = imagecolorallocate($im, 0, 0, 0);
$white = imagecolorallocate($im, 255, 255, 255);
// Make the background white
imagefilledrectangle($im, 0, 0, 700, 250, $white);
// Load the gd font from local folder
// and write 'GeeksforGeeks'
$font = imageloadfont('./Hollow_8x16_LE.gdf');
imagestring($im, $font, 0, 0, 'GeeksforGeeks', $black);
// Scale the image bigger
$im1 = imagescale($im, 700);
// Output to browser
header('Content-type:image/png');
imagepng($im1);
imagedestroy($im);
?>
输出:
程序2(在图像上书写):
<?php
// Create an image instance
$im = imagecreatefrompng(
'https://media.geeksforgeeks.org/wp-content/uploads/geeksforgeeks-13.png');
// Prepare the red color
$red = imagecolorallocate($im, 255, 0, 0);
// Load the gd font from local folder and write 'GeeksforGeeks'
$font = imageloadfont('./Hollow_8x16_LE.gdf');
imagestring($im, $font, 200, 100, 'GeeksforGeeks', $red);
// Output to browser
header('Content-type:image/png');
imagepng($im);
imagedestroy($im);
?>
输出:
参考: https://www.php.net/manual/en/function.imageloadfont.php
相关用法
- d3.js d3.map.set()用法及代码示例
- PHP next()用法及代码示例
- p5.js second()用法及代码示例
- PHP each()用法及代码示例
- p5.js pow()用法及代码示例
- PHP pow( )用法及代码示例
- p5.js day()用法及代码示例
- CSS url()用法及代码示例
- CSS var()用法及代码示例
- d3.js d3.set.has()用法及代码示例
- p5.js hue()用法及代码示例
- p5.js value()用法及代码示例
注:本文由纯净天空筛选整理自gurrrung大神的英文原创作品 PHP | imageloadfont() Function。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。