1
1
<?php
2
+
2
3
/**
3
4
* PHPWord
4
5
*
24
25
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
25
26
* @version 0.7.0
26
27
*/
27
-
28
28
use PhpOffice \PhpWord \Exceptions \InvalidStyleException ;
29
29
30
30
/**
31
31
* Class PHPWord_Style_Font
32
32
*/
33
- class PHPWord_Style_Font
34
- {
33
+ class PHPWord_Style_Font {
34
+
35
35
const UNDERLINE_NONE = 'none ' ;
36
36
const UNDERLINE_DASH = 'dash ' ;
37
37
const UNDERLINE_DASHHEAVY = 'dashHeavy ' ;
@@ -50,7 +50,6 @@ class PHPWord_Style_Font
50
50
const UNDERLINE_WAVYDOUBLE = 'wavyDbl ' ;
51
51
const UNDERLINE_WAVYHEAVY = 'wavyHeavy ' ;
52
52
const UNDERLINE_WORDS = 'words ' ;
53
-
54
53
const FGCOLOR_YELLOW = 'yellow ' ;
55
54
const FGCOLOR_LIGHTGREEN = 'green ' ;
56
55
const FGCOLOR_CYAN = 'cyan ' ;
@@ -158,14 +157,20 @@ class PHPWord_Style_Font
158
157
*/
159
158
private $ lineHeight = 1.0 ;
160
159
160
+ /**
161
+ * Font Content Type
162
+ *
163
+ * @var string
164
+ */
165
+ private $ _hint = PHPWord::DEFAULT_FONT_CONTENT_TYPE ;
166
+
161
167
/**
162
168
* New font style
163
169
*
164
170
* @param string $type Type of font
165
171
* @param array $paragraphStyle Paragraph styles definition
166
172
*/
167
- public function __construct ($ type = 'text ' , $ paragraphStyle = null )
168
- {
173
+ public function __construct ($ type = 'text ' , $ paragraphStyle = null ) {
169
174
$ this ->_type = $ type ;
170
175
171
176
if ($ paragraphStyle instanceof PHPWord_Style_Paragraph) {
@@ -184,8 +189,7 @@ public function __construct($type = 'text', $paragraphStyle = null)
184
189
* @param array $style
185
190
* @return $this
186
191
*/
187
- public function setArrayStyle (array $ style = array ())
188
- {
192
+ public function setArrayStyle (array $ style = array ()) {
189
193
foreach ($ style as $ key => $ value ) {
190
194
if ($ key === 'line-height ' ) {
191
195
$ this ->setLineHeight ($ value );
@@ -205,8 +209,7 @@ public function setArrayStyle(array $style = array())
205
209
* @param string $key
206
210
* @param mixed $value
207
211
*/
208
- public function setStyleValue ($ key , $ value )
209
- {
212
+ public function setStyleValue ($ key , $ value ) {
210
213
$ method = 'set ' . substr ($ key , 1 );
211
214
if (method_exists ($ this , $ method )) {
212
215
$ this ->$ method ($ value );
@@ -218,8 +221,7 @@ public function setStyleValue($key, $value)
218
221
*
219
222
* @return bool
220
223
*/
221
- public function getName ()
222
- {
224
+ public function getName () {
223
225
return $ this ->_name ;
224
226
}
225
227
@@ -229,22 +231,21 @@ public function getName()
229
231
* @param string $pValue
230
232
* @return PHPWord_Style_Font
231
233
*/
232
- public function setName ($ pValue = PHPWord::DEFAULT_FONT_NAME )
233
- {
234
+ public function setName ($ pValue = PHPWord::DEFAULT_FONT_NAME ) {
234
235
if (is_null ($ pValue ) || $ pValue == '' ) {
235
236
$ pValue = PHPWord::DEFAULT_FONT_NAME ;
236
237
}
237
238
$ this ->_name = $ pValue ;
238
239
return $ this ;
239
240
}
241
+
240
242
241
243
/**
242
244
* Get font size
243
245
*
244
246
* @return int|float
245
247
*/
246
- public function getSize ()
247
- {
248
+ public function getSize () {
248
249
return $ this ->_size ;
249
250
}
250
251
@@ -254,8 +255,7 @@ public function getSize()
254
255
* @param int|float $pValue
255
256
* @return PHPWord_Style_Font
256
257
*/
257
- public function setSize ($ pValue = PHPWord::DEFAULT_FONT_SIZE )
258
- {
258
+ public function setSize ($ pValue = PHPWord::DEFAULT_FONT_SIZE ) {
259
259
if (!is_numeric ($ pValue )) {
260
260
$ pValue = PHPWord::DEFAULT_FONT_SIZE ;
261
261
}
@@ -268,8 +268,7 @@ public function setSize($pValue = PHPWord::DEFAULT_FONT_SIZE)
268
268
*
269
269
* @return bool
270
270
*/
271
- public function getBold ()
272
- {
271
+ public function getBold () {
273
272
return $ this ->_bold ;
274
273
}
275
274
@@ -279,8 +278,7 @@ public function getBold()
279
278
* @param bool $pValue
280
279
* @return PHPWord_Style_Font
281
280
*/
282
- public function setBold ($ pValue = false )
283
- {
281
+ public function setBold ($ pValue = false ) {
284
282
if (!is_bool ($ pValue )) {
285
283
$ pValue = false ;
286
284
}
@@ -293,8 +291,7 @@ public function setBold($pValue = false)
293
291
*
294
292
* @return bool
295
293
*/
296
- public function getItalic ()
297
- {
294
+ public function getItalic () {
298
295
return $ this ->_italic ;
299
296
}
300
297
@@ -304,8 +301,7 @@ public function getItalic()
304
301
* @param bool $pValue
305
302
* @return PHPWord_Style_Font
306
303
*/
307
- public function setItalic ($ pValue = false )
308
- {
304
+ public function setItalic ($ pValue = false ) {
309
305
if (!is_bool ($ pValue )) {
310
306
$ pValue = false ;
311
307
}
@@ -318,8 +314,7 @@ public function setItalic($pValue = false)
318
314
*
319
315
* @return bool
320
316
*/
321
- public function getSuperScript ()
322
- {
317
+ public function getSuperScript () {
323
318
return $ this ->_superScript ;
324
319
}
325
320
@@ -329,8 +324,7 @@ public function getSuperScript()
329
324
* @param bool $pValue
330
325
* @return PHPWord_Style_Font
331
326
*/
332
- public function setSuperScript ($ pValue = false )
333
- {
327
+ public function setSuperScript ($ pValue = false ) {
334
328
if (!is_bool ($ pValue )) {
335
329
$ pValue = false ;
336
330
}
@@ -344,8 +338,7 @@ public function setSuperScript($pValue = false)
344
338
*
345
339
* @return bool
346
340
*/
347
- public function getSubScript ()
348
- {
341
+ public function getSubScript () {
349
342
return $ this ->_subScript ;
350
343
}
351
344
@@ -355,8 +348,7 @@ public function getSubScript()
355
348
* @param bool $pValue
356
349
* @return PHPWord_Style_Font
357
350
*/
358
- public function setSubScript ($ pValue = false )
359
- {
351
+ public function setSubScript ($ pValue = false ) {
360
352
if (!is_bool ($ pValue )) {
361
353
$ pValue = false ;
362
354
}
@@ -370,8 +362,7 @@ public function setSubScript($pValue = false)
370
362
*
371
363
* @return string
372
364
*/
373
- public function getUnderline ()
374
- {
365
+ public function getUnderline () {
375
366
return $ this ->_underline ;
376
367
}
377
368
@@ -381,8 +372,7 @@ public function getUnderline()
381
372
* @param string $pValue
382
373
* @return PHPWord_Style_Font
383
374
*/
384
- public function setUnderline ($ pValue = PHPWord_Style_Font::UNDERLINE_NONE )
385
- {
375
+ public function setUnderline ($ pValue = PHPWord_Style_Font::UNDERLINE_NONE ) {
386
376
if ($ pValue == '' ) {
387
377
$ pValue = PHPWord_Style_Font::UNDERLINE_NONE ;
388
378
}
@@ -395,8 +385,7 @@ public function setUnderline($pValue = PHPWord_Style_Font::UNDERLINE_NONE)
395
385
*
396
386
* @return bool
397
387
*/
398
- public function getStrikethrough ()
399
- {
388
+ public function getStrikethrough () {
400
389
return $ this ->_strikethrough ;
401
390
}
402
391
@@ -406,8 +395,7 @@ public function getStrikethrough()
406
395
* @param bool $pValue
407
396
* @return PHPWord_Style_Font
408
397
*/
409
- public function setStrikethrough ($ pValue = false )
410
- {
398
+ public function setStrikethrough ($ pValue = false ) {
411
399
if (!is_bool ($ pValue )) {
412
400
$ pValue = false ;
413
401
}
@@ -420,8 +408,7 @@ public function setStrikethrough($pValue = false)
420
408
*
421
409
* @return string
422
410
*/
423
- public function getColor ()
424
- {
411
+ public function getColor () {
425
412
return $ this ->_color ;
426
413
}
427
414
@@ -431,8 +418,7 @@ public function getColor()
431
418
* @param string $pValue
432
419
* @return PHPWord_Style_Font
433
420
*/
434
- public function setColor ($ pValue = PHPWord::DEFAULT_FONT_COLOR )
435
- {
421
+ public function setColor ($ pValue = PHPWord::DEFAULT_FONT_COLOR ) {
436
422
if (is_null ($ pValue ) || $ pValue == '' ) {
437
423
$ pValue = PHPWord::DEFAULT_FONT_COLOR ;
438
424
}
@@ -445,8 +431,7 @@ public function setColor($pValue = PHPWord::DEFAULT_FONT_COLOR)
445
431
*
446
432
* @return bool
447
433
*/
448
- public function getFgColor ()
449
- {
434
+ public function getFgColor () {
450
435
return $ this ->_fgColor ;
451
436
}
452
437
@@ -456,8 +441,7 @@ public function getFgColor()
456
441
* @param string $pValue
457
442
* @return PHPWord_Style_Font
458
443
*/
459
- public function setFgColor ($ pValue = null )
460
- {
444
+ public function setFgColor ($ pValue = null ) {
461
445
$ this ->_fgColor = $ pValue ;
462
446
return $ this ;
463
447
}
@@ -467,8 +451,7 @@ public function setFgColor($pValue = null)
467
451
*
468
452
* @return string
469
453
*/
470
- public function getStyleType ()
471
- {
454
+ public function getStyleType () {
472
455
return $ this ->_type ;
473
456
}
474
457
@@ -477,21 +460,18 @@ public function getStyleType()
477
460
*
478
461
* @return PHPWord_Style_Paragraph
479
462
*/
480
- public function getParagraphStyle ()
481
- {
463
+ public function getParagraphStyle () {
482
464
return $ this ->_paragraphStyle ;
483
465
}
484
466
485
-
486
467
/**
487
468
* Set the line height
488
469
*
489
470
* @param int|float|string $lineHeight
490
471
* @return $this
491
472
* @throws InvalidStyleException
492
473
*/
493
- public function setLineHeight ($ lineHeight )
494
- {
474
+ public function setLineHeight ($ lineHeight ) {
495
475
if (is_string ($ lineHeight )) {
496
476
$ lineHeight = floatval (preg_replace ('/[^0-9\.\,]/ ' , '' , $ lineHeight ));
497
477
}
@@ -508,8 +488,28 @@ public function setLineHeight($lineHeight)
508
488
/**
509
489
* @return int|float
510
490
*/
511
- public function getLineHeight ()
512
- {
491
+ public function getLineHeight () {
513
492
return $ this ->lineHeight ;
514
493
}
494
+ /**
495
+ * Get Font Content Type
496
+ *
497
+ * @return bool
498
+ */
499
+ public function getHint () {
500
+ return $ this ->_hint ;
501
+ }
502
+ /**
503
+ * Set Font Content Type
504
+ *
505
+ * @param string $pValue
506
+ * @return PHPWord_Style_Font
507
+ */
508
+ public function setHint ($ pValue = PHPWord::DEFAULT_FONT_CONTENT_TYPE ) {
509
+ if (is_null ($ pValue ) || $ pValue == '' ) {
510
+ $ pValue = PHPWord::DEFAULT_FONT_CONTENT_TYPE ;
511
+ }
512
+ $ this ->_hint = $ pValue ;
513
+ return $ this ;
514
+ }
515
515
}
0 commit comments