diff --git a/README.md b/README.md index 72f300d..0c44369 100644 --- a/README.md +++ b/README.md @@ -330,7 +330,7 @@ $image->text( 'This text appears right after title using smart boundaries', array( 'x' => 50, - 'y' => 100 + $boundary['height'], + 'y' => $boundary['y'] + $boundary['height'], 'width' => 800, 'fontpath' => '/fonts/opensans.ttf', 'fontsize' => 20, diff --git a/composer.json b/composer.json index 7e68047..23d31b1 100644 --- a/composer.json +++ b/composer.json @@ -1,6 +1,6 @@ { "name": "antonlukin/poster-editor", - "version": "5.11", + "version": "5.12", "description": "Wrapper for PHP's GD Library for easy image manipulation", "keywords": ["php", "image", "text", "gd"], "homepage": "https://github.com/antonlukin/poster-editor", diff --git a/example/boundary.php b/example/boundary.php index 871fcd6..f49d0b4 100644 --- a/example/boundary.php +++ b/example/boundary.php @@ -42,7 +42,7 @@ 'This text appears right after title using smart boundaries', array( 'x' => 50, - 'y' => 100 + $boundary['height'], + 'y' => $boundary['y'] + $boundary['height'], 'width' => 800, 'fontpath' => 'fonts/opensans.ttf', 'fontsize' => 20, diff --git a/src/PosterEditor.php b/src/PosterEditor.php index d6c2d0a..04d4f69 100644 --- a/src/PosterEditor.php +++ b/src/PosterEditor.php @@ -23,7 +23,7 @@ * @package PosterEditor * @author Anton Lukin * @license MIT License (http://www.opensource.org/licenses/mit-license.php) - * @version Release: 5.11 + * @version Release: 5.12 * @link https://github.com/antonlukin/poster-editor */ class PosterEditor @@ -774,7 +774,14 @@ public function text($text, $options = array(), &$boundary = array()) $lines = explode(PHP_EOL, $text); // Set default boundary vaules. - $boundary = array_merge(array('width' => 0, 'height' => 0)); + $boundary = array_merge( + array( + 'x' => $options['x'], + 'y' => $options['y'], + 'width' => 0, + 'height' => 0, + ) + ); foreach ($lines as $index => $line) { list($x, $y, $width, $height) = $this->getOffset($options, $lines, $index); @@ -785,10 +792,8 @@ public function text($text, $options = array(), &$boundary = array()) // Draw single line $this->drawLine($line, $options, $width, $x, $y, $color, $last); - $boundary = array( - 'width' => max($width, $boundary['width']), - 'height' => $boundary['height'] + $height, - ); + $boundary['width'] = max($width, $boundary['width']); + $boundary['height'] = $boundary['height'] + $height; } return $this;