header( "Content-type: image/png" );
if ( class_exists( 'Imagick' ) ) {
$width = 1360;
$height = 400;
$s = 60;
$fontfile = __DIR__ . '/font.ttf';
$x = 50;
$y = 150;
$t = 'Agenda Fantasy Halloween Font';
// Create a new Imagick object
$image = new Imagick();
// Set the image background color
$backgroundColor = new ImagickPixel( 'white' );
$image->newImage( $width, $height, $backgroundColor );
// Create a new drawing object
$draw = new ImagickDraw();
$draw->setFont( $fontfile );
$draw->setFontSize( $s );
// Set the font color
$textColor = new ImagickPixel( 'black' );
$draw->setFillColor( $textColor );
// Set font features for ligatures and kerning
$fontFeatures = "liga=1,kern=1"; // Enable ligatures and kerning
$draw->setTextEncoding( 'UTF-8' );
$image->setFont( $fontfile );
$image->drawImage( $draw );
$image->annotateImage( $draw, $x, $y, 0, $t );
$image->setImageFormat( 'png' );
echo $image->getImageBlob();
}
Chuyển đổi văn bản thành hình ảnh áp dụng font chữ kèm theo
Theo dõi
Đăng nhập
0 Góp ý
Cũ nhất