|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
##DOC-SIGNATURE## |
|
4
|
|
|
|
|
5
|
|
|
This file is part of WideImage. |
|
6
|
|
|
|
|
7
|
|
|
WideImage is free software; you can redistribute it and/or modify |
|
8
|
|
|
it under the terms of the GNU Lesser General Public License as published by |
|
9
|
|
|
the Free Software Foundation; either version 2.1 of the License, or |
|
10
|
|
|
(at your option) any later version. |
|
11
|
|
|
|
|
12
|
|
|
WideImage is distributed in the hope that it will be useful, |
|
13
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
14
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
15
|
|
|
GNU Lesser General Public License for more details. |
|
16
|
|
|
|
|
17
|
|
|
You should have received a copy of the GNU Lesser General Public License |
|
18
|
|
|
along with WideImage; if not, write to the Free Software |
|
19
|
|
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
|
20
|
|
|
|
|
21
|
|
|
* @package WideImage |
|
22
|
|
|
**/ |
|
23
|
|
|
|
|
24
|
|
|
namespace WideImage\Font; |
|
25
|
|
|
|
|
26
|
|
|
/** |
|
27
|
|
|
* PS font support class |
|
28
|
|
|
* |
|
29
|
|
|
* @package WideImage |
|
30
|
|
|
*/ |
|
31
|
|
|
class PS |
|
32
|
|
|
{ |
|
33
|
|
|
public $size; |
|
34
|
|
|
public $color; |
|
35
|
|
|
public $handle; |
|
36
|
|
|
|
|
37
|
|
|
public function __construct($file, $size, $color, $bgcolor = null) |
|
38
|
|
|
{ |
|
39
|
|
|
$this->handle = imagepsloadfont($file); |
|
40
|
|
|
$this->size = $size; |
|
41
|
|
|
$this->color = $color; |
|
42
|
|
|
|
|
43
|
|
|
if ($bgcolor === null) { |
|
44
|
|
|
$this->bgcolor = $color; |
|
|
|
|
|
|
45
|
|
|
} else { |
|
46
|
|
|
$this->color = $color; |
|
47
|
|
|
} |
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
|
|
public function writeText($image, $x, $y, $text, $angle = 0) |
|
51
|
|
|
{ |
|
52
|
|
|
if ($image->isTrueColor()) { |
|
53
|
|
|
$image->alphaBlending(true); |
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
|
|
imagepstext($image->getHandle(), $text, $this->handle, $this->size, $this->color, $this->bgcolor, $x, $y, 0, 0, $angle, 4); |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
|
|
public function __destruct() |
|
60
|
|
|
{ |
|
61
|
|
|
imagepsfreefont($this->handle); |
|
62
|
|
|
$this->handle = null; |
|
63
|
|
|
} |
|
64
|
|
|
} |
|
65
|
|
|
|
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: