@@ -210,7 +210,21 @@ Rotate image. Set an angle in degrees and optional color of the uncovered zone a
210210```
211211$image->text(string $text, array $options = array(), array &$boundary = array())
212212```
213- Draw text on image. Look for all possible options in the examples below.
213+ Draw text on image. Possible options:
214+ - ** x** : X-Coordinate of text box starting point.
215+ - ** y** : Y-Coordinate of text box starting point.
216+ - ** width** : Width of text box. Calculated from image size for nulled values.
217+ - ** height** : Height of text box. Calculated from image size for nulled values.
218+ - ** fontsize** : Maximum font size. Will be scaled down if the text doesn't fit box.
219+ - ** color** : Color of text. Can be rgb-array or '#ffffff' format.
220+ - ** lineheight** : Line height of text.
221+ - ** opacity** : Text opacity from 0 to 100.
222+ - ** horizontal** : Horizontal alignment. Can be left/right/center/justify.
223+ - ** vertical** : Vertical alginment. Can be top/center/bottom/justify.
224+ - ** fontpath** : Path to .ttf font file.
225+ - ** debug** : Draws text box rectangle if true.
226+
227+ Use boundary to get actual dimensions of the drawn text box. See detailed examples below.
214228
215229## Examples
216230
@@ -238,11 +252,11 @@ $image->text(
238252 array(
239253 'x' => 100,
240254 'y' => 100,
241- 'width' => 1000, // Use image width if null or unset
242- 'height' => 400, // Use image height if null or unset
243- 'horizontal' => 'center', // Can be left/right/center
244- 'vertical' => 'center', // Can be top/center/bottom
245- 'fontpath' => 'fonts/opensans.ttf', // Can only be .ttf
255+ 'width' => 1000,
256+ 'height' => 400,
257+ 'horizontal' => 'center',
258+ 'vertical' => 'center',
259+ 'fontpath' => 'fonts/opensans.ttf',
246260 'fontsize' => 24,
247261 'lineheight' => 1.75,
248262 'color' => '#ffffff',
@@ -256,6 +270,35 @@ $image->show('jpg', 70);
256270#### Result
257271<img src =" example/samples/center.jpg " alt =" multiline centered text " width =" 400 " />
258272
273+ ### Draw and justify multiline text
274+ ``` php
275+ $image = new PosterEditor\PosterEditor();
276+ $image->make('images/bridge.jpg')->fit(900, 600);
277+ $image->blackout(70);
278+
279+ $image->text(
280+ 'Lorem ipsum dolor d d 4 g sit amet, consectetur adipiscing et, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex eas commodo consequat sdfsdfl', // phpcs:ignore
281+ array(
282+ 'x' => 100,
283+ 'y' => 100,
284+ 'width' => 600,
285+ 'height' => 400,
286+ 'horizontal' => 'justify',
287+ 'vertical' => 'justify',
288+ 'fontpath' => 'fonts/opensans.ttf',
289+ 'fontsize' => 20,
290+ 'lineheight' => 1.5,
291+ 'color' => '#ffffff',
292+ 'opacity' => 1,
293+ 'debug' => true,
294+ )
295+ );
296+
297+ $image->show('png');
298+ ```
299+ #### Result
300+ <img src =" example/samples/justify.png " alt =" multiline justified text " width =" 400 " />
301+
259302### Use boundaries to draw one title right after another
260303``` php
261304$image = new PosterEditor\PosterEditor();
0 commit comments