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) {
@@ -182,8 +187,7 @@ public function __construct($type = 'text', $paragraphStyle = null)
182
187
* @param array $style
183
188
* @return $this
184
189
*/
185
- public function setArrayStyle (array $ style = array ())
186
- {
190
+ public function setArrayStyle (array $ style = array ()) {
187
191
foreach ($ style as $ key => $ value ) {
188
192
if ($ key === 'line-height ' ) {
189
193
$ this ->setLineHeight ($ value );
@@ -203,8 +207,7 @@ public function setArrayStyle(array $style = array())
203
207
* @param string $key
204
208
* @param mixed $value
205
209
*/
206
- public function setStyleValue ($ key , $ value )
207
- {
210
+ public function setStyleValue ($ key , $ value ) {
208
211
$ method = 'set ' . substr ($ key , 1 );
209
212
if (method_exists ($ this , $ method )) {
210
213
$ this ->$ method ($ value );
@@ -216,8 +219,7 @@ public function setStyleValue($key, $value)
216
219
*
217
220
* @return bool
218
221
*/
219
- public function getName ()
220
- {
222
+ public function getName () {
221
223
return $ this ->_name ;
222
224
}
223
225
@@ -227,22 +229,21 @@ public function getName()
227
229
* @param string $pValue
228
230
* @return PHPWord_Style_Font
229
231
*/
230
- public function setName ($ pValue = PHPWord::DEFAULT_FONT_NAME )
231
- {
232
+ public function setName ($ pValue = PHPWord::DEFAULT_FONT_NAME ) {
232
233
if (is_null ($ pValue ) || $ pValue == '' ) {
233
234
$ pValue = PHPWord::DEFAULT_FONT_NAME ;
234
235
}
235
236
$ this ->_name = $ pValue ;
236
237
return $ this ;
237
238
}
239
+
238
240
239
241
/**
240
242
* Get font size
241
243
*
242
244
* @return int|float
243
245
*/
244
- public function getSize ()
245
- {
246
+ public function getSize () {
246
247
return $ this ->_size ;
247
248
}
248
249
@@ -252,8 +253,7 @@ public function getSize()
252
253
* @param int|float $pValue
253
254
* @return PHPWord_Style_Font
254
255
*/
255
- public function setSize ($ pValue = PHPWord::DEFAULT_FONT_SIZE )
256
- {
256
+ public function setSize ($ pValue = PHPWord::DEFAULT_FONT_SIZE ) {
257
257
if (!is_numeric ($ pValue )) {
258
258
$ pValue = PHPWord::DEFAULT_FONT_SIZE ;
259
259
}
@@ -266,8 +266,7 @@ public function setSize($pValue = PHPWord::DEFAULT_FONT_SIZE)
266
266
*
267
267
* @return bool
268
268
*/
269
- public function getBold ()
270
- {
269
+ public function getBold () {
271
270
return $ this ->_bold ;
272
271
}
273
272
@@ -277,8 +276,7 @@ public function getBold()
277
276
* @param bool $pValue
278
277
* @return PHPWord_Style_Font
279
278
*/
280
- public function setBold ($ pValue = false )
281
- {
279
+ public function setBold ($ pValue = false ) {
282
280
if (!is_bool ($ pValue )) {
283
281
$ pValue = false ;
284
282
}
@@ -291,8 +289,7 @@ public function setBold($pValue = false)
291
289
*
292
290
* @return bool
293
291
*/
294
- public function getItalic ()
295
- {
292
+ public function getItalic () {
296
293
return $ this ->_italic ;
297
294
}
298
295
@@ -302,8 +299,7 @@ public function getItalic()
302
299
* @param bool $pValue
303
300
* @return PHPWord_Style_Font
304
301
*/
305
- public function setItalic ($ pValue = false )
306
- {
302
+ public function setItalic ($ pValue = false ) {
307
303
if (!is_bool ($ pValue )) {
308
304
$ pValue = false ;
309
305
}
@@ -316,8 +312,7 @@ public function setItalic($pValue = false)
316
312
*
317
313
* @return bool
318
314
*/
319
- public function getSuperScript ()
320
- {
315
+ public function getSuperScript () {
321
316
return $ this ->_superScript ;
322
317
}
323
318
@@ -327,8 +322,7 @@ public function getSuperScript()
327
322
* @param bool $pValue
328
323
* @return PHPWord_Style_Font
329
324
*/
330
- public function setSuperScript ($ pValue = false )
331
- {
325
+ public function setSuperScript ($ pValue = false ) {
332
326
if (!is_bool ($ pValue )) {
333
327
$ pValue = false ;
334
328
}
@@ -342,8 +336,7 @@ public function setSuperScript($pValue = false)
342
336
*
343
337
* @return bool
344
338
*/
345
- public function getSubScript ()
346
- {
339
+ public function getSubScript () {
347
340
return $ this ->_subScript ;
348
341
}
349
342
@@ -353,8 +346,7 @@ public function getSubScript()
353
346
* @param bool $pValue
354
347
* @return PHPWord_Style_Font
355
348
*/
356
- public function setSubScript ($ pValue = false )
357
- {
349
+ public function setSubScript ($ pValue = false ) {
358
350
if (!is_bool ($ pValue )) {
359
351
$ pValue = false ;
360
352
}
@@ -368,8 +360,7 @@ public function setSubScript($pValue = false)
368
360
*
369
361
* @return string
370
362
*/
371
- public function getUnderline ()
372
- {
363
+ public function getUnderline () {
373
364
return $ this ->_underline ;
374
365
}
375
366
@@ -379,8 +370,7 @@ public function getUnderline()
379
370
* @param string $pValue
380
371
* @return PHPWord_Style_Font
381
372
*/
382
- public function setUnderline ($ pValue = PHPWord_Style_Font::UNDERLINE_NONE )
383
- {
373
+ public function setUnderline ($ pValue = PHPWord_Style_Font::UNDERLINE_NONE ) {
384
374
if ($ pValue == '' ) {
385
375
$ pValue = PHPWord_Style_Font::UNDERLINE_NONE ;
386
376
}
@@ -393,8 +383,7 @@ public function setUnderline($pValue = PHPWord_Style_Font::UNDERLINE_NONE)
393
383
*
394
384
* @return bool
395
385
*/
396
- public function getStrikethrough ()
397
- {
386
+ public function getStrikethrough () {
398
387
return $ this ->_strikethrough ;
399
388
}
400
389
@@ -404,8 +393,7 @@ public function getStrikethrough()
404
393
* @param bool $pValue
405
394
* @return PHPWord_Style_Font
406
395
*/
407
- public function setStrikethrough ($ pValue = false )
408
- {
396
+ public function setStrikethrough ($ pValue = false ) {
409
397
if (!is_bool ($ pValue )) {
410
398
$ pValue = false ;
411
399
}
@@ -418,8 +406,7 @@ public function setStrikethrough($pValue = false)
418
406
*
419
407
* @return string
420
408
*/
421
- public function getColor ()
422
- {
409
+ public function getColor () {
423
410
return $ this ->_color ;
424
411
}
425
412
@@ -429,8 +416,7 @@ public function getColor()
429
416
* @param string $pValue
430
417
* @return PHPWord_Style_Font
431
418
*/
432
- public function setColor ($ pValue = PHPWord::DEFAULT_FONT_COLOR )
433
- {
419
+ public function setColor ($ pValue = PHPWord::DEFAULT_FONT_COLOR ) {
434
420
if (is_null ($ pValue ) || $ pValue == '' ) {
435
421
$ pValue = PHPWord::DEFAULT_FONT_COLOR ;
436
422
}
@@ -443,8 +429,7 @@ public function setColor($pValue = PHPWord::DEFAULT_FONT_COLOR)
443
429
*
444
430
* @return bool
445
431
*/
446
- public function getFgColor ()
447
- {
432
+ public function getFgColor () {
448
433
return $ this ->_fgColor ;
449
434
}
450
435
@@ -454,8 +439,7 @@ public function getFgColor()
454
439
* @param string $pValue
455
440
* @return PHPWord_Style_Font
456
441
*/
457
- public function setFgColor ($ pValue = null )
458
- {
442
+ public function setFgColor ($ pValue = null ) {
459
443
$ this ->_fgColor = $ pValue ;
460
444
return $ this ;
461
445
}
@@ -465,8 +449,7 @@ public function setFgColor($pValue = null)
465
449
*
466
450
* @return string
467
451
*/
468
- public function getStyleType ()
469
- {
452
+ public function getStyleType () {
470
453
return $ this ->_type ;
471
454
}
472
455
@@ -475,21 +458,18 @@ public function getStyleType()
475
458
*
476
459
* @return PHPWord_Style_Paragraph
477
460
*/
478
- public function getParagraphStyle ()
479
- {
461
+ public function getParagraphStyle () {
480
462
return $ this ->_paragraphStyle ;
481
463
}
482
464
483
-
484
465
/**
485
466
* Set the line height
486
467
*
487
468
* @param int|float|string $lineHeight
488
469
* @return $this
489
470
* @throws InvalidStyleException
490
471
*/
491
- public function setLineHeight ($ lineHeight )
492
- {
472
+ public function setLineHeight ($ lineHeight ) {
493
473
if (is_string ($ lineHeight )) {
494
474
$ lineHeight = floatval (preg_replace ('/[^0-9\.\,]/ ' , '' , $ lineHeight ));
495
475
}
@@ -506,8 +486,28 @@ public function setLineHeight($lineHeight)
506
486
/**
507
487
* @return int|float
508
488
*/
509
- public function getLineHeight ()
510
- {
489
+ public function getLineHeight () {
511
490
return $ this ->lineHeight ;
512
491
}
492
+ /**
493
+ * Get Font Content Type
494
+ *
495
+ * @return bool
496
+ */
497
+ public function getHint () {
498
+ return $ this ->_hint ;
499
+ }
500
+ /**
501
+ * Set Font Content Type
502
+ *
503
+ * @param string $pValue
504
+ * @return PHPWord_Style_Font
505
+ */
506
+ public function setHint ($ pValue = PHPWord::DEFAULT_FONT_CONTENT_TYPE ) {
507
+ if (is_null ($ pValue ) || $ pValue == '' ) {
508
+ $ pValue = PHPWord::DEFAULT_FONT_CONTENT_TYPE ;
509
+ }
510
+ $ this ->_hint = $ pValue ;
511
+ return $ this ;
512
+ }
513
513
}
0 commit comments