是否可以在一个font-size
内的图片上设置不同的imagettftext()
?
我已设法在图像上输出所需的文字。现在,我想在较大的$subheadliner_thu_1
中显示font-size
。我不想把它放在一个新的imagettftext()
中,因为文本的长度将来可能会改变。因此,设置坐标不应用于$undercard_thu_4
。
这是我的代码:
<?php
header('Content-type: image/jpeg');
$jpg_image = imagecreatefromjpeg('img/pkp-empty.jpg');
$white = imagecolorallocate($jpg_image, 255, 255, 255);
$font_path = 'fonts/calibri.ttf';
$undercard_thu_1 = "amelie lens";
$undercard_thu_1 = strtoupper($undercard_thu_1);
$undercard_thu_2 = "beautifull swimmers";
$undercard_thu_2 = strtoupper($undercard_thu_2);
$undercard_thu_4 = "cypress hill";
$undercard_thu_4 = strtoupper($undercard_thu_4);
$subheadliner_thu_1 = "chance the rapper";
$subheadliner_thu_1 = strtoupper($subheadliner_thu_1);
$lineup_upper1 = $undercard_thu_1 . ' • ' . $undercard_thu_2;
$lineup1 = wordwrap($lineup_upper1, 60, "\n", false);
$lineup_upper2 = $subheadliner_thu_1 . ' • ' . $undercard_thu_4;
$lineup2 = wordwrap($lineup_upper2, 60, "\n", false);
imagettftext($jpg_image, 25, 0, 295, 532, $white, $font_path, $lineup1);
imagettftext($jpg_image, 25, 0, 72, 579, $white, $font_path, $lineup2);
imagejpeg($jpg_image);
imagedestroy($jpg_image);
?>