Я сам нашел решение, чтобы получить его жирным шрифтом. У меня нет желания объяснять все, потому что я тот, кто задал этот вопрос, поэтому я просто передаю новый код с полученным изображением. Завтра я попробую подчеркнуть ссылку. Если кто-нибудь знает ответ на этот вопрос, я приму этот ответ. Обратите внимание, что я немного изменил код, который не нужен, чтобы заставить код работать.
Код:
<?php
$username = 'WietsedeVries';
$textSize = 10;
$text = addslashes("Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed malesuada aliquet dolor, vitae tristique http://www.google.com pellentesque et.");
$maxWidth = 448;
//Create image
$im = imagecreate(468, 60);
// Black background and White text
$bg = imagecolorallocate($im, 0, 0, 0);
$textColor = imagecolorallocate($im, 255, 255, 255);
// Write Bold Username in image
$usernameTotal = '@' . $username . ':';
imagettftext($im, $textSize, 0, 10, $textSize + 10, $textColor, './arialbd.ttf', $usernameTotal);
// Create white space with the width of the username
$usernameBox = imagettfbbox($textSize, 0, './arialbd.ttf', $usernameTotal);
$usernameWidth = $usernameBox[4] - $usernameBox[0];
$whiteSpace = '';
$whiteSpaceWidth = 0;
while($whiteSpaceWidth < $usernameWidth) {
$whiteSpace .= ' ';
$whiteSpaceBox = imagettfbbox($textSize, 0, './arial.ttf', $whiteSpace);
$whiteSpaceWidth = $whiteSpaceBox[4] - $whiteSpaceBox[0];
}
// Split in multiple lines
$words = explode(' ', $text);
array_unshift($words, $whiteSpace);
$lines = array();
$line = "";
foreach ($words as $word) {
$box = imagettfbbox($textSize, 0, './arial.ttf', $line . $word);
$width = $box[4] - $box[0];
if($width > $maxWidth) {
$line = trim($line);
$line .= "\n";
}
$line .= $word . ' ';
}
// Write the text in the image
imagettftext($im, $textSize, 0, 10, $textSize + 10, $textColor, './arial.ttf', $whiteSpace . ' ' . $line);
// Output the image
header('Content-type: image/png');
imagepng($im);
imagedestroy($im);
?>
В результате получается следующее изображение:
[/g0]