gpt4 book ai didi

php - 使用 php GD 库输出带下划线文本的图像

转载 作者:搜寻专家 更新时间:2023-10-31 20:56:34 24 4
gpt4 key购买 nike

使用 GD 或任何其他库显示带下划线的文本并将结果输出为图像的最佳方法是什么?

最佳答案

您可以尝试使用 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 = "&#x0332;U&#x0332;d&#x0332;e&#x0332;r&#x0332;l&#x0332;i&#x0332;n&#x0332;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);
?>

关于php - 使用 php GD 库输出带下划线文本的图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/692411/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com