使用 GD 或任何其他库显示带下划线的文本并将结果输出为图像的最佳方法是什么?
Prakaz
问问题
2580 次
3 回答
3
您可以尝试使用 Unicode 下划线组合字符U+0332
。
<?php
// Set the content-type
header('Content-type: image/png');
// Create the image
$im = imagecreatetruecolor(400, 30);
// Create some colors
$white = imagecolorallocate($im, 255, 255, 255);
$black = imagecolorallocate($im, 0, 0, 0);
imagefilledrectangle($im, 0, 0, 399, 29, $white);
// The text to draw
$text = "̲U̲d̲e̲r̲l̲i̲n̲e";
// Replace path by your own font path
$font = 'arial.ttf';
// Add the text
imagettftext($im, 20, 0, 10, 20, $black, $font, $text);
// Using imagepng() results in clearer text compared with imagejpeg()
imagepng($im);
imagedestroy($im);
?>
于 2009-03-28T11:39:10.357 回答
0
有很多免费的 PHP CAPTCHA 带有很多自定义,下载一个看看幕后到底发生了什么。也看看这个链接
高温高压
于 2009-03-28T08:59:00.053 回答
0
我正在使用这个...
$font = imageloadfont($font_file);
$font_width = ImageFontWidth($font);
$font_height = ImageFontHeight($font);
$str_width = strlen($text)*$font_width;
ImageLine($image, $left, $top+$font_height, $left+$str_width, $top+$font_height, $color);
于 2013-04-03T10:43:06.963 回答