Skip to content

Commit

Permalink
Add docs
Browse files Browse the repository at this point in the history
  • Loading branch information
riasvdv committed Mar 5, 2024
1 parent 01551fc commit 3c9fe83
Show file tree
Hide file tree
Showing 7 changed files with 65 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .phpunit.cache/test-results

Large diffs are not rendered by default.

62 changes: 62 additions & 0 deletions docs/image-manipulations/text.md
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);
```
2 changes: 2 additions & 0 deletions tests/Manipulations/TextTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,6 @@
'width 200' => [[30, 'ffffff', 0, 50, 0, getTestSupportPath('testFiles/comic.ttf'), 200]],
'width 300' => [[30, 'ffffff', 0, 50, 0, getTestSupportPath('testFiles/comic.ttf'), 300]],
'angle 10' => [[30, 'ffffff', 0, 50, 10, getTestSupportPath('testFiles/comic.ttf')]],
'red' => [[30, 'ff0000', 0, 50, 0, getTestSupportPath('testFiles/comic.ttf')]],
'blue' => [[30, '0000ff', 0, 50, 0, getTestSupportPath('testFiles/comic.ttf')]],
]);
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 3c9fe83

Please sign in to comment.