【发布时间】:2016-12-25 17:33:21
【问题描述】:
我需要使用 GD 库在另一个文本之后粘贴一个文本。 Example here。我尝试通过以下方式做到这一点
$text = wordwrap($text, 80, "\n");
$count = substr_count($text, "\n");
$string_number = 14;
$pos = 0;
if ($count >= $string_number) {
for ($i = 0; $i < 14; $i++) {
$pos = stripos($text, "\n", $pos) + 1;
}
$text = substr($text, 0, $pos);
//Attempt to calculate coordinates of a text block
$text_cord = imagettfbbox(14, 0, $font_300_path, $text);
//And paste text after the end coordinate
imagettftext($image, 14, 0, 130, $text_cord[3], $blue, font_300_path, 'Need to paste');
}
imagettftext($image, 14, 0, 130, 293, $black, $font_300_path, $text);
但如果我这样做,我会得到this
所以,我的问题是,如何在另一个文本块之后粘贴文本?
【问题讨论】:
-
你是说粘贴?
-
哦,是的!固定。
-
您的代码不完整。请粘贴您用于创建图像的所有代码,以便重现您的问题。见How to create a Minimal, Complete, and Verifiable example。