|
| 1 | +# Texter |
| 2 | +Texter helps to write Bangla/English text on image with PHP GD. It also has featurs like align, maintain lineheight, color settings etc. |
| 3 | +## Example |
| 4 | +```php |
| 5 | + $texter = new nazmulpcc\Texter; |
| 6 | + $image = imagecreate(500, 300); |
| 7 | + imagecolorallocate($image, 255, 255, 255); |
| 8 | + $texter->startFrom(50, 90)->width(400)->on($image)->align('center')->fontSize(30)->color('333333'); |
| 9 | + $texter->text('আমার সোনার বাংলা, আমি তোমায় ভালবাসি Lorem ipsum dolor sit amet.....')->write(); |
| 10 | +``` |
| 11 | +It will give you something like this: |
| 12 | + |
| 13 | + |
| 14 | +## Installation |
| 15 | +You can easily install **Texter** via composer or you can manually download the package and include them in your code. |
| 16 | +### Composer |
| 17 | +```shell |
| 18 | + composer require nazmulpcc/Texter |
| 19 | +``` |
| 20 | + |
| 21 | +### Manual |
| 22 | +- Download/Clone this repo. |
| 23 | +- Download/Clone [mirazmac/Unicode2Bijoy](https://github.com/mirazmac/Unicode2Bijoy) . |
| 24 | +- Include Texter.php and Unicode2Bijoy.php in your code and you are ready to go. |
| 25 | + |
| 26 | +## Documentation |
| 27 | +Each method is fairly well documented in the source code. A few important methods: |
| 28 | +** startFrom(x, y): ** Set up the co-ordinates from which Texter will start writing. |
| 29 | +** width($w): ** Width of the boundary inside which Texter will write text. |
| 30 | +** align($position): ** Set the horizontal alignment to left, right or center/centre. Default is left. |
| 31 | +** on($image) ** / ** image($image): ** Set the image on which Texter will write. Image is passed by reference. |
| 32 | +** fontSize($size): ** Set the font size. $size can be point or pixel, like ```$texter->fontSize('15pt')``` or ```$texter->fontSize('15px'). If 'pt' or 'px' is absent, the gd default is used. |
| 33 | +** color($hex): ** / ** color($red, $green, $blue): ** Both hex and RGB are accepted as text color. |
| 34 | +** text($text): ** Add text to be written. |
| 35 | +** lineHeight($height): ** The line height. $height can be in pixel or as a percentage of the text height. |
| 36 | +** write(): ** Call this guy to do the job or if you want to start a new line. |
| 37 | +All public functions can be chained up. So you can always do things like: |
| 38 | +``` $texter->startFrom(10, 10)->color(0, 0, 0)->align('center')->width(500)->text('Hellow World')->write() ``` |
| 39 | +**Note: ** Before you write a piece of text, you must at least set the starting points(**startFrom**), **width**, and **image**. |
| 40 | + |
| 41 | +## About Texter |
| 42 | +I developed this out of pure frustration that PHP, one of the most widely used coding language doesn't support Bangla because GD can't handle complex fonts. There are room for a lot of improvements which I will try to accomplish gradually. Please contribute if you can. |
| 43 | + |
| 44 | +## License |
| 45 | +This project is lincensed under [DBAD](http://www.dbad-license.org) license. |
0 commit comments