-
-
Notifications
You must be signed in to change notification settings - Fork 128
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
65 additions
and
1 deletion.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
--- | ||
title: Adding text | ||
weight: 9 | ||
--- | ||
|
||
Using the `text` method you can easily position and add text. By default, it will be placed in the top left corner of the image. | ||
|
||
```php | ||
$image->text('Hello there!'); | ||
``` | ||
|
||
## Text position | ||
|
||
Using the `x` and `y` parameters, you can set the location of the text. | ||
|
||
### Example usage | ||
|
||
```php | ||
$image->text('Hello there!', x: 10, y: 10); | ||
``` | ||
|
||
## Font size | ||
|
||
Using the `fontSize` parameter, you can set the font size in pixels. | ||
|
||
### Example usage | ||
|
||
```php | ||
$image->text('Hello there!', fontSize: 100); | ||
``` | ||
|
||
## Font color | ||
|
||
Using the `color` parameter, you can set the font color. | ||
|
||
The color can be a color name (see [all available color names](https://developer.mozilla.org/en/docs/Web/CSS/color_value#Color_keywords)) or hexadecimal RGB(A). | ||
|
||
### Example usage | ||
|
||
```php | ||
$image->text('Hello there!', color: ''); | ||
``` | ||
|
||
## Font family | ||
|
||
Using the `fontPath` parameter, which is required when using `GD` you can specify a path to a font to use | ||
|
||
### Example usage | ||
|
||
```php | ||
$image->text('Hello there!', fontPath: __DIR__ . '/arial.ttf'); | ||
``` | ||
|
||
## Wrapping text | ||
|
||
Using the `width` parameter, you can define a max width in pixels that the text should be and the package will wrap the text automatically. | ||
|
||
### Example usage | ||
|
||
```php | ||
$image->text('Hello there! This is a long piece of text that we should wrap.', width: 1000); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file added
BIN
+43.2 KB
...Test__it_can_insert_text_to_image_with_data_set_dataset_gd__dataset_blue__1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+43.2 KB
...tTest__it_can_insert_text_to_image_with_data_set_dataset_gd__dataset_red__1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+46.7 KB
..._it_can_insert_text_to_image_with_data_set_dataset_imagick__dataset_blue__1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+46.7 KB
...__it_can_insert_text_to_image_with_data_set_dataset_imagick__dataset_red__1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.