1 | <?php |
||
5 | class Font |
||
6 | { |
||
7 | const FONT_NORMAL = 400; |
||
8 | const FONT_BOLD = 700; |
||
9 | |||
10 | const UNDERLINE_NONE = 0; |
||
11 | const UNDERLINE_ONCE = 1; |
||
12 | const UNDERLINE_TWICE = 2; |
||
13 | |||
14 | const SCRIPT_NONE = 0; |
||
15 | const SCRIPT_SUPER = 1; |
||
16 | const SCRIPT_SUB = 2; |
||
17 | |||
18 | /** |
||
19 | * Index to the FONT record. |
||
20 | * @var integer |
||
21 | */ |
||
22 | public $index = 0; |
||
23 | |||
24 | /** |
||
25 | * The font name (ASCII). |
||
26 | * @var string |
||
27 | */ |
||
28 | public $name = 'Arial'; |
||
29 | |||
30 | /** |
||
31 | * Height of font (1/20 of a point) |
||
32 | * @var integer |
||
33 | */ |
||
34 | public $size = 10; |
||
35 | |||
36 | /** |
||
37 | * Bold style |
||
38 | * @var integer |
||
39 | */ |
||
40 | public $bold = self::FONT_NORMAL; |
||
41 | |||
42 | /** |
||
43 | * Bit specifiying if the font is italic. |
||
44 | * @var integer |
||
45 | */ |
||
46 | public $italic = 0; |
||
47 | |||
48 | /** |
||
49 | * Index to the cell's color |
||
50 | * @var integer |
||
51 | */ |
||
52 | public $color = 0x7FFF; |
||
53 | |||
54 | /** |
||
55 | * The text underline property |
||
56 | * @var integer |
||
57 | */ |
||
58 | public $underline = self::UNDERLINE_NONE; |
||
59 | |||
60 | /** |
||
61 | * Bit specifiying if the font has strikeout. |
||
62 | * @var integer |
||
63 | */ |
||
64 | public $strikeout = 0; |
||
65 | |||
66 | /** |
||
67 | * Bit specifiying if the font has outline. |
||
68 | * @var integer |
||
69 | */ |
||
70 | public $outline = 0; |
||
71 | |||
72 | /** |
||
73 | * Bit specifiying if the font has shadow. |
||
74 | * @var integer |
||
75 | */ |
||
76 | public $shadow = 0; |
||
77 | |||
78 | /** |
||
79 | * 2 bytes specifiying the script type for the font. |
||
80 | * @var integer |
||
81 | */ |
||
82 | public $script = self::SCRIPT_NONE; |
||
83 | |||
84 | /** |
||
85 | * Sets the boldness of the text. |
||
86 | * @param bool $bold |
||
87 | * |
||
88 | * @return Font |
||
89 | */ |
||
90 | public function setBold($bold = true) |
||
96 | |||
97 | /** |
||
98 | * Sets the cell's font color |
||
99 | * |
||
100 | * @param string|integer $color either a string (like 'blue'), or an integer (range is [8...63]). |
||
101 | * |
||
102 | * @return Font |
||
103 | */ |
||
104 | public function setColor($color) |
||
110 | |||
111 | /** |
||
112 | * Sets the underline of the text |
||
113 | * |
||
114 | * @param integer $underline The value for underline. Possible values are: |
||
115 | * UNDERLINE_ONCE => underline, UNDERLINE_TWICE => double underline. |
||
116 | * |
||
117 | * @return Font |
||
118 | */ |
||
119 | public function setUnderline($underline) |
||
125 | |||
126 | /** |
||
127 | * Sets the font style as italic |
||
128 | * @param bool $italic |
||
129 | * |
||
130 | * @return Font |
||
131 | */ |
||
132 | public function setItalic($italic = true) |
||
138 | |||
139 | /** |
||
140 | * Sets the font size |
||
141 | * |
||
142 | * @param integer $size The font size (in pixels I think). |
||
143 | * |
||
144 | * @return Font |
||
145 | */ |
||
146 | public function setSize($size) |
||
152 | |||
153 | /** |
||
154 | * Sets font as strikeout |
||
155 | * @param bool $strikeout |
||
156 | * |
||
157 | * @return Font |
||
158 | */ |
||
159 | public function setStrikeOut($strikeout = true) |
||
165 | |||
166 | /** |
||
167 | * Sets outlining for a font. |
||
168 | * @param bool $outline |
||
169 | * |
||
170 | * @return Font |
||
171 | */ |
||
172 | public function setOutLine($outline = true) |
||
178 | |||
179 | /** |
||
180 | * Sets font as shadow. |
||
181 | * @param bool $shadow |
||
182 | * |
||
183 | * @return Font |
||
184 | */ |
||
185 | public function setShadow($shadow = true) |
||
191 | |||
192 | /** |
||
193 | * @param bool $enable |
||
194 | * |
||
195 | * @return Font |
||
196 | */ |
||
197 | public function setSuperScript($enable = true) |
||
203 | |||
204 | /** |
||
205 | * @param bool $enable |
||
206 | * |
||
207 | * @return Font |
||
208 | */ |
||
209 | public function setSubScript($enable = true) |
||
215 | |||
216 | /** |
||
217 | * Sets the font name. |
||
218 | * |
||
219 | * @param string $name The font name. Possible values are: |
||
220 | * 'Times New Roman', 'Arial', 'Courier'. |
||
221 | * |
||
222 | * @return Font |
||
223 | */ |
||
224 | public function setName($name) |
||
230 | |||
231 | /** |
||
232 | * Returns a unique hash key for a font. |
||
233 | * The elements that form the key are arranged to increase the probability of |
||
234 | * generating a unique key. Elements that hold a large range of numbers |
||
235 | * (eg. color) are placed between two binary elements such as italic |
||
236 | * |
||
237 | * @return string A key for this font |
||
238 | */ |
||
239 | public function getKey() |
||
249 | |||
250 | /** |
||
251 | * @return int |
||
252 | */ |
||
253 | public function getIndex() |
||
257 | |||
258 | /** |
||
259 | * @return string |
||
260 | */ |
||
261 | public function getName() |
||
265 | |||
266 | /** |
||
267 | * @return int |
||
268 | */ |
||
269 | public function getSize() |
||
273 | |||
274 | /** |
||
275 | * @return int |
||
276 | */ |
||
277 | public function getBold() |
||
281 | |||
282 | /** |
||
283 | * @return int |
||
284 | */ |
||
285 | public function getItalic() |
||
289 | |||
290 | /** |
||
291 | * @return int |
||
292 | */ |
||
293 | public function getColor() |
||
297 | |||
298 | /** |
||
299 | * @return int |
||
300 | */ |
||
301 | public function getUnderline() |
||
305 | |||
306 | /** |
||
307 | * @return int |
||
308 | */ |
||
309 | public function getStrikeout() |
||
313 | |||
314 | /** |
||
315 | * @return int |
||
316 | */ |
||
317 | public function getOutline() |
||
321 | |||
322 | /** |
||
323 | * @return int |
||
324 | */ |
||
325 | public function getShadow() |
||
329 | |||
330 | /** |
||
331 | * @return int |
||
332 | */ |
||
333 | public function getScript() |
||
337 | |||
338 | /** |
||
339 | * @param int $index |
||
340 | */ |
||
341 | public function setIndex($index) |
||
345 | } |
||
346 |