PHP GD 라이브러리를 사용하여 밑줄이 그어진 텍스트가있는 이미지를 출력합니다
문제
밑줄이 그어진 텍스트를 표시하고 결과를 GD 또는 다른 라이브러리로 이미지로 출력하는 가장 좋은 방법은 무엇입니까?
해결책
유니 코드 밑줄 결합 문자를 사용해 볼 수 있습니다 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);
?>
다른 팁
많은 사용자 정의와 함께 제공되는 무료 PHP 보안 문자가 많이 있습니다. 또한 이것을 살펴보십시오 링크
HTH
나는 이것을 사용하고있다 ...
$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);
제휴하지 않습니다 StackOverflow