作者共发了4篇帖子。
GD庫輸出帶有字體的文字
1楼 巨大八爪鱼 2015-6-13 10:03
<?php
header("Content-type:image/png");

$im = imagecreatetruecolor(550, 70);
$colour = imagecolorallocate($im, 224, 223, 238);
imagefill($im, 0, 0, $colour);

$fontfile = "/var/www/arslanbar/2/fonts/DejaVuSans.ttf" ;
$colour = imagecolorallocate($im, mt_rand(0, 100), mt_rand(50, 150), mt_rand(100, 200));
imagettftext($im, 35, 0, 4, 38, $colour, $fontfile, "Which is the best one?");

$fontfile = "/var/www/arslanbar/2/fonts/showg.ttf" ;
$colour = imagecolorallocate($im, mt_rand(0, 100), mt_rand(50, 150), mt_rand(100, 200));
imagettftext($im, 22, 0, 4, 65, $colour, $fontfile, "Do you think they are important?");

imagepng($im);
imagedestroy($im);
?>
2楼 巨大八爪鱼 2015-6-13 10:04
無需打開字體文件,只需指定文件路徑。
3楼 巨大八爪鱼 2015-6-13 10:05

文字顏色是隨機生成的!
4楼 巨大八爪鱼 2015-6-13 10:05

回复帖子

内容:
用户名: 您目前是匿名发表
验证码:
 
 
©2010-2025 Arslanbar [手机版] [桌面版]
除非另有声明,本站采用知识共享署名-相同方式共享 3.0 Unported许可协议进行许可。