Skip to content

Commit f95cb28

Browse files
committed
first commit
0 parents  commit f95cb28

File tree

8 files changed

+474
-0
lines changed

8 files changed

+474
-0
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/vendor

composer.json

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"name": "nazmulpcc/texter",
3+
"description": "A PHP class which makes it easier to write Bangla text on images. Supports multi-line, align etc.",
4+
"type": "library",
5+
"license": "MIT",
6+
"require": {
7+
"php": "^5.3.3 || ^7.0",
8+
"mirazmac/unicode2bijoy": "1.*"
9+
},
10+
11+
"autoload": {
12+
"psr-4": { "nazmulpcc\\": "src/" }
13+
},
14+
15+
"suggest": {
16+
"ext-gd": "to use GD library based image processing."
17+
}
18+
}

composer.lock

+61
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

example/index.php

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?php
2+
require '../vendor/autoload.php';
3+
$texter = new nazmulpcc\Texter;
4+
5+
$image = imagecreate(500, 300);
6+
imagecolorallocate($image, 255, 255, 255);
7+
8+
$texter->startFrom(50, 90)->width(400)->on($image);
9+
$texter->text('আমার সোনার বাংলা, আমি তোমায় ভালবাসি Lorem ipsum dolor sit amet.....')->write();
10+
11+
header('Content-type:image/jpeg');
12+
imagejpeg($image);

readme.md

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
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+
![Result](http://i.imgur.com/phfgEqy.jpg "Result")
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

Comments
 (0)