Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
116 / 116 |
|
100.00% |
59 / 59 |
CRAP | |
100.00% |
1 / 1 |
Font | |
100.00% |
116 / 116 |
|
100.00% |
59 / 59 |
61 | |
100.00% |
1 / 1 |
__construct | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
getStyleValues | |
100.00% |
34 / 34 |
|
100.00% |
1 / 1 |
1 | |||
getStyleType | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getName | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
setName | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
getHint | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
setHint | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
getSize | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
setSize | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
getColor | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
setColor | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
isBold | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
setBold | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
isItalic | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
setItalic | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
getUnderline | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
setUnderline | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
isSuperScript | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
setSuperScript | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
isSubScript | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
setSubScript | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
isStrikethrough | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
setStrikethrough | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
isDoubleStrikethrough | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
setDoubleStrikethrough | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
isSmallCaps | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
setSmallCaps | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
isAllCaps | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
setAllCaps | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getFgColor | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
setFgColor | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
getBgColor | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
setBgColor | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getScale | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
setScale | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
getSpacing | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
setSpacing | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
getKerning | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
setKerning | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
isNoProof | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
setNoProof | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
getLineHeight | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
setLineHeight | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
getParagraph | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
setParagraph | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
isRTL | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
setRTL | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
getShading | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
setShading | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
getLang | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
setLang | |
100.00% |
4 / 4 |
|
100.00% |
1 / 1 |
3 | |||
isHidden | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
setHidden | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
getPosition | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
setPosition | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
setWhiteSpace | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
getWhiteSpace | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
setFallbackFont | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
getFallbackFont | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 |
1 | <?php |
2 | |
3 | /** |
4 | * This file is part of PHPWord - A pure PHP library for reading and writing |
5 | * word processing documents. |
6 | * |
7 | * PHPWord is free software distributed under the terms of the GNU Lesser |
8 | * General Public License version 3 as published by the Free Software Foundation. |
9 | * |
10 | * For the full copyright and license information, please read the LICENSE |
11 | * file that was distributed with this source code. For the full list of |
12 | * contributors, visit https://github.com/PHPOffice/PHPWord/contributors. |
13 | * |
14 | * @see https://github.com/PHPOffice/PHPWord |
15 | * |
16 | * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 |
17 | */ |
18 | |
19 | namespace PhpOffice\PhpWord\Style; |
20 | |
21 | use PhpOffice\PhpWord\Settings; |
22 | use PhpOffice\PhpWord\Shared\Validate; |
23 | |
24 | /** |
25 | * Font style. |
26 | */ |
27 | class Font extends AbstractStyle |
28 | { |
29 | /** |
30 | * Underline types. |
31 | * |
32 | * @const string |
33 | */ |
34 | const UNDERLINE_NONE = 'none'; |
35 | const UNDERLINE_DASH = 'dash'; |
36 | const UNDERLINE_DASHHEAVY = 'dashHeavy'; |
37 | const UNDERLINE_DASHLONG = 'dashLong'; |
38 | const UNDERLINE_DASHLONGHEAVY = 'dashLongHeavy'; |
39 | const UNDERLINE_DOUBLE = 'dbl'; |
40 | const UNDERLINE_DOTDASH = 'dotDash'; |
41 | const UNDERLINE_DOTDASHHEAVY = 'dotDashHeavy'; |
42 | const UNDERLINE_DOTDOTDASH = 'dotDotDash'; |
43 | const UNDERLINE_DOTDOTDASHHEAVY = 'dotDotDashHeavy'; |
44 | const UNDERLINE_DOTTED = 'dotted'; |
45 | const UNDERLINE_DOTTEDHEAVY = 'dottedHeavy'; |
46 | const UNDERLINE_HEAVY = 'heavy'; |
47 | const UNDERLINE_SINGLE = 'single'; |
48 | const UNDERLINE_WAVY = 'wavy'; |
49 | const UNDERLINE_WAVYDOUBLE = 'wavyDbl'; |
50 | const UNDERLINE_WAVYHEAVY = 'wavyHeavy'; |
51 | const UNDERLINE_WORDS = 'words'; |
52 | |
53 | /** |
54 | * Foreground colors. |
55 | * |
56 | * @const string |
57 | */ |
58 | const FGCOLOR_YELLOW = 'yellow'; |
59 | const FGCOLOR_LIGHTGREEN = 'green'; |
60 | const FGCOLOR_CYAN = 'cyan'; |
61 | const FGCOLOR_MAGENTA = 'magenta'; |
62 | const FGCOLOR_BLUE = 'blue'; |
63 | const FGCOLOR_RED = 'red'; |
64 | const FGCOLOR_DARKBLUE = 'darkBlue'; |
65 | const FGCOLOR_DARKCYAN = 'darkCyan'; |
66 | const FGCOLOR_DARKGREEN = 'darkGreen'; |
67 | const FGCOLOR_DARKMAGENTA = 'darkMagenta'; |
68 | const FGCOLOR_DARKRED = 'darkRed'; |
69 | const FGCOLOR_DARKYELLOW = 'darkYellow'; |
70 | const FGCOLOR_DARKGRAY = 'darkGray'; |
71 | const FGCOLOR_LIGHTGRAY = 'lightGray'; |
72 | const FGCOLOR_BLACK = 'black'; |
73 | |
74 | /** |
75 | * Aliases. |
76 | * |
77 | * @var array |
78 | */ |
79 | protected $aliases = ['line-height' => 'lineHeight', 'letter-spacing' => 'spacing']; |
80 | |
81 | /** |
82 | * Font style type. |
83 | * |
84 | * @var string |
85 | */ |
86 | private $type; |
87 | |
88 | /** |
89 | * Font name. |
90 | * |
91 | * @var string |
92 | */ |
93 | private $name; |
94 | |
95 | /** |
96 | * Font Content Type. |
97 | * |
98 | * @var string |
99 | */ |
100 | private $hint; |
101 | |
102 | /** |
103 | * Font size. |
104 | * |
105 | * @var float|int |
106 | */ |
107 | private $size; |
108 | |
109 | /** |
110 | * Font color. |
111 | * |
112 | * @var string |
113 | */ |
114 | private $color; |
115 | |
116 | /** |
117 | * Bold. |
118 | * |
119 | * @var bool |
120 | */ |
121 | private $bold; |
122 | |
123 | /** |
124 | * Italic. |
125 | * |
126 | * @var bool |
127 | */ |
128 | private $italic; |
129 | |
130 | /** |
131 | * Undeline. |
132 | * |
133 | * @var string |
134 | */ |
135 | private $underline = self::UNDERLINE_NONE; |
136 | |
137 | /** |
138 | * Superscript. |
139 | * |
140 | * @var bool |
141 | */ |
142 | private $superScript = false; |
143 | |
144 | /** |
145 | * Subscript. |
146 | * |
147 | * @var bool |
148 | */ |
149 | private $subScript = false; |
150 | |
151 | /** |
152 | * Strikethrough. |
153 | * |
154 | * @var bool |
155 | */ |
156 | private $strikethrough; |
157 | |
158 | /** |
159 | * Double strikethrough. |
160 | * |
161 | * @var bool |
162 | */ |
163 | private $doubleStrikethrough; |
164 | |
165 | /** |
166 | * Small caps. |
167 | * |
168 | * @var bool |
169 | * |
170 | * @see http://www.schemacentral.com/sc/ooxml/e-w_smallCaps-1.html |
171 | */ |
172 | private $smallCaps; |
173 | |
174 | /** |
175 | * All caps. |
176 | * |
177 | * @var bool |
178 | * |
179 | * @see http://www.schemacentral.com/sc/ooxml/e-w_caps-1.html |
180 | */ |
181 | private $allCaps; |
182 | |
183 | /** |
184 | * Foreground/highlight. |
185 | * |
186 | * @var string |
187 | */ |
188 | private $fgColor; |
189 | |
190 | /** |
191 | * Expanded/compressed text: 0-600 (percent). |
192 | * |
193 | * @var int |
194 | * |
195 | * @since 0.12.0 |
196 | * @see http://www.schemacentral.com/sc/ooxml/e-w_w-1.html |
197 | */ |
198 | private $scale; |
199 | |
200 | /** |
201 | * Character spacing adjustment: twip. |
202 | * |
203 | * @var float|int |
204 | * |
205 | * @since 0.12.0 |
206 | * @see http://www.schemacentral.com/sc/ooxml/e-w_spacing-2.html |
207 | */ |
208 | private $spacing; |
209 | |
210 | /** |
211 | * Font kerning: halfpoint. |
212 | * |
213 | * @var float|int |
214 | * |
215 | * @since 0.12.0 |
216 | * @see http://www.schemacentral.com/sc/ooxml/e-w_kern-1.html |
217 | */ |
218 | private $kerning; |
219 | |
220 | /** |
221 | * Paragraph style. |
222 | * |
223 | * @var Paragraph |
224 | */ |
225 | private $paragraph; |
226 | |
227 | /** |
228 | * Shading. |
229 | * |
230 | * @var Shading |
231 | */ |
232 | private $shading; |
233 | |
234 | /** |
235 | * Right to left languages. |
236 | * |
237 | * @var ?bool |
238 | */ |
239 | private $rtl; |
240 | |
241 | /** |
242 | * noProof (disables AutoCorrect). |
243 | * |
244 | * @var bool |
245 | * http://www.datypic.com/sc/ooxml/e-w_noProof-1.html |
246 | */ |
247 | private $noProof; |
248 | |
249 | /** |
250 | * Languages. |
251 | * |
252 | * @var null|Language |
253 | */ |
254 | private $lang; |
255 | |
256 | /** |
257 | * Hidden text. |
258 | * |
259 | * @var bool |
260 | * |
261 | * @see http://www.datypic.com/sc/ooxml/e-w_vanish-1.html |
262 | */ |
263 | private $hidden; |
264 | |
265 | /** |
266 | * Vertically Raised or Lowered Text. |
267 | * |
268 | * @var int Signed Half-Point Measurement |
269 | * |
270 | * @see http://www.datypic.com/sc/ooxml/e-w_position-1.html |
271 | */ |
272 | private $position; |
273 | |
274 | /** |
275 | * Preservation of white space in html. |
276 | * |
277 | * @var string Value used for css white-space |
278 | */ |
279 | private $whiteSpace = ''; |
280 | |
281 | /** |
282 | * Generic font as fallback for html. |
283 | * |
284 | * @var string generic font name |
285 | */ |
286 | private $fallbackFont = ''; |
287 | |
288 | /** |
289 | * Create new font style. |
290 | * |
291 | * @param string $type Type of font |
292 | * @param AbstractStyle|array|string $paragraph Paragraph styles definition |
293 | */ |
294 | public function __construct($type = 'text', $paragraph = null) |
295 | { |
296 | $this->type = $type; |
297 | $this->setParagraph($paragraph); |
298 | } |
299 | |
300 | /** |
301 | * Get style values. |
302 | * |
303 | * @return array |
304 | * |
305 | * @since 0.12.0 |
306 | */ |
307 | public function getStyleValues() |
308 | { |
309 | return [ |
310 | 'name' => $this->getStyleName(), |
311 | 'basic' => [ |
312 | 'name' => $this->getName(), |
313 | 'size' => $this->getSize(), |
314 | 'color' => $this->getColor(), |
315 | 'hint' => $this->getHint(), |
316 | ], |
317 | 'style' => [ |
318 | 'bold' => $this->isBold(), |
319 | 'italic' => $this->isItalic(), |
320 | 'underline' => $this->getUnderline(), |
321 | 'strike' => $this->isStrikethrough(), |
322 | 'dStrike' => $this->isDoubleStrikethrough(), |
323 | 'super' => $this->isSuperScript(), |
324 | 'sub' => $this->isSubScript(), |
325 | 'smallCaps' => $this->isSmallCaps(), |
326 | 'allCaps' => $this->isAllCaps(), |
327 | 'fgColor' => $this->getFgColor(), |
328 | 'hidden' => $this->isHidden(), |
329 | ], |
330 | 'spacing' => [ |
331 | 'scale' => $this->getScale(), |
332 | 'spacing' => $this->getSpacing(), |
333 | 'kerning' => $this->getKerning(), |
334 | 'position' => $this->getPosition(), |
335 | ], |
336 | 'paragraph' => $this->getParagraph(), |
337 | 'rtl' => $this->isRTL(), |
338 | 'shading' => $this->getShading(), |
339 | 'lang' => $this->getLang(), |
340 | 'whiteSpace' => $this->getWhiteSpace(), |
341 | 'fallbackFont' => $this->getFallbackFont(), |
342 | ]; |
343 | } |
344 | |
345 | /** |
346 | * Get style type. |
347 | * |
348 | * @return string |
349 | */ |
350 | public function getStyleType() |
351 | { |
352 | return $this->type; |
353 | } |
354 | |
355 | /** |
356 | * Get font name. |
357 | * |
358 | * @return string |
359 | */ |
360 | public function getName() |
361 | { |
362 | return $this->name; |
363 | } |
364 | |
365 | /** |
366 | * Set font name. |
367 | * |
368 | * @param string $value |
369 | * |
370 | * @return self |
371 | */ |
372 | public function setName($value = null) |
373 | { |
374 | $this->name = $value; |
375 | |
376 | return $this; |
377 | } |
378 | |
379 | /** |
380 | * Get Font Content Type. |
381 | * |
382 | * @return string |
383 | */ |
384 | public function getHint() |
385 | { |
386 | return $this->hint; |
387 | } |
388 | |
389 | /** |
390 | * Set Font Content Type. |
391 | * |
392 | * @param string $value |
393 | * |
394 | * @return self |
395 | */ |
396 | public function setHint($value = null) |
397 | { |
398 | $this->hint = $value; |
399 | |
400 | return $this; |
401 | } |
402 | |
403 | /** |
404 | * Get font size. |
405 | * |
406 | * @return float|int |
407 | */ |
408 | public function getSize() |
409 | { |
410 | return $this->size; |
411 | } |
412 | |
413 | /** |
414 | * Set font size. |
415 | * |
416 | * @param float|int $value |
417 | * |
418 | * @return self |
419 | */ |
420 | public function setSize($value = null) |
421 | { |
422 | $this->size = $this->setNumericVal($value, $this->size); |
423 | |
424 | return $this; |
425 | } |
426 | |
427 | /** |
428 | * Get font color. |
429 | * |
430 | * @return string |
431 | */ |
432 | public function getColor() |
433 | { |
434 | return $this->color; |
435 | } |
436 | |
437 | /** |
438 | * Set font color. |
439 | * |
440 | * @param string $value |
441 | * |
442 | * @return self |
443 | */ |
444 | public function setColor($value = null) |
445 | { |
446 | $this->color = $value; |
447 | |
448 | return $this; |
449 | } |
450 | |
451 | /** |
452 | * Get bold. |
453 | * |
454 | * @return bool |
455 | */ |
456 | public function isBold() |
457 | { |
458 | return $this->bold; |
459 | } |
460 | |
461 | /** |
462 | * Set bold. |
463 | * |
464 | * @param bool $value |
465 | * |
466 | * @return self |
467 | */ |
468 | public function setBold($value = true) |
469 | { |
470 | $this->bold = $this->setBoolVal($value, $this->bold); |
471 | |
472 | return $this; |
473 | } |
474 | |
475 | /** |
476 | * Get italic. |
477 | * |
478 | * @return bool |
479 | */ |
480 | public function isItalic() |
481 | { |
482 | return $this->italic; |
483 | } |
484 | |
485 | /** |
486 | * Set italic. |
487 | * |
488 | * @param bool $value |
489 | * |
490 | * @return self |
491 | */ |
492 | public function setItalic($value = true) |
493 | { |
494 | $this->italic = $this->setBoolVal($value, $this->italic); |
495 | |
496 | return $this; |
497 | } |
498 | |
499 | /** |
500 | * Get underline. |
501 | * |
502 | * @return string |
503 | */ |
504 | public function getUnderline() |
505 | { |
506 | return $this->underline; |
507 | } |
508 | |
509 | /** |
510 | * Set underline. |
511 | * |
512 | * @param string $value |
513 | * |
514 | * @return self |
515 | */ |
516 | public function setUnderline($value = self::UNDERLINE_NONE) |
517 | { |
518 | $this->underline = $this->setNonEmptyVal($value, self::UNDERLINE_NONE); |
519 | |
520 | return $this; |
521 | } |
522 | |
523 | /** |
524 | * Get superscript. |
525 | * |
526 | * @return bool |
527 | */ |
528 | public function isSuperScript() |
529 | { |
530 | return $this->superScript; |
531 | } |
532 | |
533 | /** |
534 | * Set superscript. |
535 | * |
536 | * @param bool $value |
537 | * |
538 | * @return self |
539 | */ |
540 | public function setSuperScript($value = true) |
541 | { |
542 | return $this->setPairedVal($this->superScript, $this->subScript, $value); |
543 | } |
544 | |
545 | /** |
546 | * Get subscript. |
547 | * |
548 | * @return bool |
549 | */ |
550 | public function isSubScript() |
551 | { |
552 | return $this->subScript; |
553 | } |
554 | |
555 | /** |
556 | * Set subscript. |
557 | * |
558 | * @param bool $value |
559 | * |
560 | * @return self |
561 | */ |
562 | public function setSubScript($value = true) |
563 | { |
564 | return $this->setPairedVal($this->subScript, $this->superScript, $value); |
565 | } |
566 | |
567 | /** |
568 | * Get strikethrough. |
569 | */ |
570 | public function isStrikethrough(): ?bool |
571 | { |
572 | return $this->strikethrough; |
573 | } |
574 | |
575 | /** |
576 | * Set strikethrough. |
577 | * |
578 | * @param bool $value |
579 | */ |
580 | public function setStrikethrough($value = true): self |
581 | { |
582 | return $this->setPairedVal($this->strikethrough, $this->doubleStrikethrough, $value); |
583 | } |
584 | |
585 | /** |
586 | * Get double strikethrough. |
587 | */ |
588 | public function isDoubleStrikethrough(): ?bool |
589 | { |
590 | return $this->doubleStrikethrough; |
591 | } |
592 | |
593 | /** |
594 | * Set double strikethrough. |
595 | * |
596 | * @param bool $value |
597 | */ |
598 | public function setDoubleStrikethrough($value = true): self |
599 | { |
600 | return $this->setPairedVal($this->doubleStrikethrough, $this->strikethrough, $value); |
601 | } |
602 | |
603 | /** |
604 | * Get small caps. |
605 | * |
606 | * @return bool |
607 | */ |
608 | public function isSmallCaps() |
609 | { |
610 | return $this->smallCaps; |
611 | } |
612 | |
613 | /** |
614 | * Set small caps. |
615 | * |
616 | * @param bool $value |
617 | * |
618 | * @return self |
619 | */ |
620 | public function setSmallCaps($value = true) |
621 | { |
622 | return $this->setPairedVal($this->smallCaps, $this->allCaps, $value); |
623 | } |
624 | |
625 | /** |
626 | * Get all caps. |
627 | * |
628 | * @return bool |
629 | */ |
630 | public function isAllCaps() |
631 | { |
632 | return $this->allCaps; |
633 | } |
634 | |
635 | /** |
636 | * Set all caps. |
637 | * |
638 | * @param bool $value |
639 | * |
640 | * @return self |
641 | */ |
642 | public function setAllCaps($value = true) |
643 | { |
644 | return $this->setPairedVal($this->allCaps, $this->smallCaps, $value); |
645 | } |
646 | |
647 | /** |
648 | * Get foreground/highlight color. |
649 | * |
650 | * @return string |
651 | */ |
652 | public function getFgColor() |
653 | { |
654 | return $this->fgColor; |
655 | } |
656 | |
657 | /** |
658 | * Set foreground/highlight color. |
659 | * |
660 | * @param string $value |
661 | * |
662 | * @return self |
663 | */ |
664 | public function setFgColor($value = null) |
665 | { |
666 | $this->fgColor = $value; |
667 | |
668 | return $this; |
669 | } |
670 | |
671 | /** |
672 | * Get background. |
673 | * |
674 | * @return string |
675 | */ |
676 | public function getBgColor() |
677 | { |
678 | return $this->getChildStyleValue($this->shading, 'fill'); |
679 | } |
680 | |
681 | /** |
682 | * Set background. |
683 | * |
684 | * @param string $value |
685 | * |
686 | * @return Table |
687 | */ |
688 | public function setBgColor($value = null) |
689 | { |
690 | $this->setShading(['fill' => $value]); |
691 | } |
692 | |
693 | /** |
694 | * Get scale. |
695 | * |
696 | * @return int |
697 | */ |
698 | public function getScale() |
699 | { |
700 | return $this->scale; |
701 | } |
702 | |
703 | /** |
704 | * Set scale. |
705 | * |
706 | * @param int $value |
707 | * |
708 | * @return self |
709 | */ |
710 | public function setScale($value = null) |
711 | { |
712 | $this->scale = $this->setIntVal($value, null); |
713 | |
714 | return $this; |
715 | } |
716 | |
717 | /** |
718 | * Get font spacing. |
719 | * |
720 | * @return float|int |
721 | */ |
722 | public function getSpacing() |
723 | { |
724 | return $this->spacing; |
725 | } |
726 | |
727 | /** |
728 | * Set font spacing. |
729 | * |
730 | * @param float|int $value |
731 | * |
732 | * @return self |
733 | */ |
734 | public function setSpacing($value = null) |
735 | { |
736 | $this->spacing = $this->setNumericVal($value, null); |
737 | |
738 | return $this; |
739 | } |
740 | |
741 | /** |
742 | * Get font kerning. |
743 | * |
744 | * @return float|int |
745 | */ |
746 | public function getKerning() |
747 | { |
748 | return $this->kerning; |
749 | } |
750 | |
751 | /** |
752 | * Set font kerning. |
753 | * |
754 | * @param float|int $value |
755 | * |
756 | * @return self |
757 | */ |
758 | public function setKerning($value = null) |
759 | { |
760 | $this->kerning = $this->setNumericVal($value, null); |
761 | |
762 | return $this; |
763 | } |
764 | |
765 | /** |
766 | * Get noProof (disables autocorrect). |
767 | * |
768 | * @return bool |
769 | */ |
770 | public function isNoProof() |
771 | { |
772 | return $this->noProof; |
773 | } |
774 | |
775 | /** |
776 | * Set noProof (disables autocorrect). |
777 | * |
778 | * @param bool $value |
779 | * |
780 | * @return $this |
781 | */ |
782 | public function setNoProof($value = false) |
783 | { |
784 | $this->noProof = $value; |
785 | |
786 | return $this; |
787 | } |
788 | |
789 | /** |
790 | * Get line height. |
791 | * |
792 | * @return float|int |
793 | */ |
794 | public function getLineHeight() |
795 | { |
796 | return $this->getParagraph()->getLineHeight(); |
797 | } |
798 | |
799 | /** |
800 | * Set lineheight. |
801 | * |
802 | * @param float|int|string $value |
803 | * |
804 | * @return self |
805 | */ |
806 | public function setLineHeight($value) |
807 | { |
808 | $this->setParagraph(['lineHeight' => $value]); |
809 | |
810 | return $this; |
811 | } |
812 | |
813 | /** |
814 | * Get paragraph style. |
815 | * |
816 | * @return Paragraph |
817 | */ |
818 | public function getParagraph() |
819 | { |
820 | return $this->paragraph; |
821 | } |
822 | |
823 | /** |
824 | * Set Paragraph. |
825 | * |
826 | * @param mixed $value |
827 | * |
828 | * @return self |
829 | */ |
830 | public function setParagraph($value = null) |
831 | { |
832 | $this->setObjectVal($value, 'Paragraph', $this->paragraph); |
833 | |
834 | return $this; |
835 | } |
836 | |
837 | /** |
838 | * Get rtl. |
839 | * |
840 | * @return ?bool |
841 | */ |
842 | public function isRTL() |
843 | { |
844 | return $this->rtl ?? Settings::isDefaultRtl(); |
845 | } |
846 | |
847 | /** |
848 | * Set rtl. |
849 | * |
850 | * @param ?bool $value |
851 | * |
852 | * @return self |
853 | */ |
854 | public function setRTL($value = true) |
855 | { |
856 | $this->rtl = $this->setBoolVal($value, $this->rtl); |
857 | |
858 | return $this; |
859 | } |
860 | |
861 | /** |
862 | * Get shading. |
863 | * |
864 | * @return Shading |
865 | */ |
866 | public function getShading() |
867 | { |
868 | return $this->shading; |
869 | } |
870 | |
871 | /** |
872 | * Set shading. |
873 | * |
874 | * @param mixed $value |
875 | * |
876 | * @return self |
877 | */ |
878 | public function setShading($value = null) |
879 | { |
880 | $this->setObjectVal($value, 'Shading', $this->shading); |
881 | |
882 | return $this; |
883 | } |
884 | |
885 | /** |
886 | * Get language. |
887 | * |
888 | * @return null|Language |
889 | */ |
890 | public function getLang() |
891 | { |
892 | return $this->lang; |
893 | } |
894 | |
895 | /** |
896 | * Set language. |
897 | * |
898 | * @param mixed $value |
899 | * |
900 | * @return self |
901 | */ |
902 | public function setLang($value = null) |
903 | { |
904 | if (is_string($value) && $value != '') { |
905 | $value = new Language($value); |
906 | } |
907 | $this->setObjectVal($value, 'Language', $this->lang); |
908 | |
909 | return $this; |
910 | } |
911 | |
912 | /** |
913 | * Get hidden text. |
914 | * |
915 | * @return bool |
916 | */ |
917 | public function isHidden() |
918 | { |
919 | return $this->hidden; |
920 | } |
921 | |
922 | /** |
923 | * Set hidden text. |
924 | * |
925 | * @param bool $value |
926 | * |
927 | * @return self |
928 | */ |
929 | public function setHidden($value = true) |
930 | { |
931 | $this->hidden = $this->setBoolVal($value, $this->hidden); |
932 | |
933 | return $this; |
934 | } |
935 | |
936 | /** |
937 | * Get position. |
938 | * |
939 | * @return int |
940 | */ |
941 | public function getPosition() |
942 | { |
943 | return $this->position; |
944 | } |
945 | |
946 | /** |
947 | * Set position. |
948 | * |
949 | * @param int $value |
950 | * |
951 | * @return self |
952 | */ |
953 | public function setPosition($value = null) |
954 | { |
955 | $this->position = $this->setIntVal($value, null); |
956 | |
957 | return $this; |
958 | } |
959 | |
960 | /** |
961 | * Set html css white-space value. It is expected that only pre-wrap and normal (default) are useful. |
962 | * |
963 | * @param null|string $value Should be one of pre-wrap, normal, nowrap, pre, pre-line, initial, inherit |
964 | */ |
965 | public function setWhiteSpace(?string $value): self |
966 | { |
967 | $this->whiteSpace = Validate::validateCSSWhiteSpace($value); |
968 | |
969 | return $this; |
970 | } |
971 | |
972 | /** |
973 | * Get html css white-space value. |
974 | */ |
975 | public function getWhiteSpace(): string |
976 | { |
977 | return $this->whiteSpace; |
978 | } |
979 | |
980 | /** |
981 | * Set generic font for fallback for html. |
982 | * |
983 | * @param string $value generic font name |
984 | */ |
985 | public function setFallbackFont(?string $value): self |
986 | { |
987 | $this->fallbackFont = Validate::validateCSSGenericFont($value); |
988 | |
989 | return $this; |
990 | } |
991 | |
992 | /** |
993 | * Get html fallback generic font. |
994 | */ |
995 | public function getFallbackFont(): string |
996 | { |
997 | return $this->fallbackFont; |
998 | } |
999 | } |