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