Skip to content

Commit d180ac7

Browse files
committed
Merge branch 'develop' of https://github.com/jhfangying/PHPWord into develop
2 parents 37dd6bc + a6e91ef commit d180ac7

File tree

4 files changed

+125
-134
lines changed

4 files changed

+125
-134
lines changed

Classes/PHPWord.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,11 @@ class PHPWord
4444
* Default font name (Arial)
4545
*/
4646
const DEFAULT_FONT_NAME = 'Arial';
47-
47+
/**
48+
* Default Font Content Type(default)
49+
* default|eastAsia|cs
50+
*/
51+
const DEFAULT_FONT_CONTENT_TYPE='default';
4852
/**
4953
* Default font size in points (10pt)
5054
*

Classes/PHPWord/Style/Font.php

Lines changed: 59 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
/**
34
* PHPWord
45
*
@@ -24,14 +25,13 @@
2425
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
2526
* @version 0.7.0
2627
*/
27-
2828
use PhpOffice\PhpWord\Exceptions\InvalidStyleException;
2929

3030
/**
3131
* Class PHPWord_Style_Font
3232
*/
33-
class PHPWord_Style_Font
34-
{
33+
class PHPWord_Style_Font {
34+
3535
const UNDERLINE_NONE = 'none';
3636
const UNDERLINE_DASH = 'dash';
3737
const UNDERLINE_DASHHEAVY = 'dashHeavy';
@@ -50,7 +50,6 @@ class PHPWord_Style_Font
5050
const UNDERLINE_WAVYDOUBLE = 'wavyDbl';
5151
const UNDERLINE_WAVYHEAVY = 'wavyHeavy';
5252
const UNDERLINE_WORDS = 'words';
53-
5453
const FGCOLOR_YELLOW = 'yellow';
5554
const FGCOLOR_LIGHTGREEN = 'green';
5655
const FGCOLOR_CYAN = 'cyan';
@@ -158,14 +157,20 @@ class PHPWord_Style_Font
158157
*/
159158
private $lineHeight = 1.0;
160159

160+
/**
161+
* Font Content Type
162+
*
163+
* @var string
164+
*/
165+
private $_hint = PHPWord::DEFAULT_FONT_CONTENT_TYPE;
166+
161167
/**
162168
* New font style
163169
*
164170
* @param string $type Type of font
165171
* @param array $paragraphStyle Paragraph styles definition
166172
*/
167-
public function __construct($type = 'text', $paragraphStyle = null)
168-
{
173+
public function __construct($type = 'text', $paragraphStyle = null) {
169174
$this->_type = $type;
170175

171176
if ($paragraphStyle instanceof PHPWord_Style_Paragraph) {
@@ -182,8 +187,7 @@ public function __construct($type = 'text', $paragraphStyle = null)
182187
* @param array $style
183188
* @return $this
184189
*/
185-
public function setArrayStyle(array $style = array())
186-
{
190+
public function setArrayStyle(array $style = array()) {
187191
foreach ($style as $key => $value) {
188192
if ($key === 'line-height') {
189193
$this->setLineHeight($value);
@@ -203,8 +207,7 @@ public function setArrayStyle(array $style = array())
203207
* @param string $key
204208
* @param mixed $value
205209
*/
206-
public function setStyleValue($key, $value)
207-
{
210+
public function setStyleValue($key, $value) {
208211
$method = 'set' . substr($key, 1);
209212
if (method_exists($this, $method)) {
210213
$this->$method($value);
@@ -216,8 +219,7 @@ public function setStyleValue($key, $value)
216219
*
217220
* @return bool
218221
*/
219-
public function getName()
220-
{
222+
public function getName() {
221223
return $this->_name;
222224
}
223225

@@ -227,22 +229,21 @@ public function getName()
227229
* @param string $pValue
228230
* @return PHPWord_Style_Font
229231
*/
230-
public function setName($pValue = PHPWord::DEFAULT_FONT_NAME)
231-
{
232+
public function setName($pValue = PHPWord::DEFAULT_FONT_NAME) {
232233
if (is_null($pValue) || $pValue == '') {
233234
$pValue = PHPWord::DEFAULT_FONT_NAME;
234235
}
235236
$this->_name = $pValue;
236237
return $this;
237238
}
239+
238240

239241
/**
240242
* Get font size
241243
*
242244
* @return int|float
243245
*/
244-
public function getSize()
245-
{
246+
public function getSize() {
246247
return $this->_size;
247248
}
248249

@@ -252,8 +253,7 @@ public function getSize()
252253
* @param int|float $pValue
253254
* @return PHPWord_Style_Font
254255
*/
255-
public function setSize($pValue = PHPWord::DEFAULT_FONT_SIZE)
256-
{
256+
public function setSize($pValue = PHPWord::DEFAULT_FONT_SIZE) {
257257
if (!is_numeric($pValue)) {
258258
$pValue = PHPWord::DEFAULT_FONT_SIZE;
259259
}
@@ -266,8 +266,7 @@ public function setSize($pValue = PHPWord::DEFAULT_FONT_SIZE)
266266
*
267267
* @return bool
268268
*/
269-
public function getBold()
270-
{
269+
public function getBold() {
271270
return $this->_bold;
272271
}
273272

@@ -277,8 +276,7 @@ public function getBold()
277276
* @param bool $pValue
278277
* @return PHPWord_Style_Font
279278
*/
280-
public function setBold($pValue = false)
281-
{
279+
public function setBold($pValue = false) {
282280
if (!is_bool($pValue)) {
283281
$pValue = false;
284282
}
@@ -291,8 +289,7 @@ public function setBold($pValue = false)
291289
*
292290
* @return bool
293291
*/
294-
public function getItalic()
295-
{
292+
public function getItalic() {
296293
return $this->_italic;
297294
}
298295

@@ -302,8 +299,7 @@ public function getItalic()
302299
* @param bool $pValue
303300
* @return PHPWord_Style_Font
304301
*/
305-
public function setItalic($pValue = false)
306-
{
302+
public function setItalic($pValue = false) {
307303
if (!is_bool($pValue)) {
308304
$pValue = false;
309305
}
@@ -316,8 +312,7 @@ public function setItalic($pValue = false)
316312
*
317313
* @return bool
318314
*/
319-
public function getSuperScript()
320-
{
315+
public function getSuperScript() {
321316
return $this->_superScript;
322317
}
323318

@@ -327,8 +322,7 @@ public function getSuperScript()
327322
* @param bool $pValue
328323
* @return PHPWord_Style_Font
329324
*/
330-
public function setSuperScript($pValue = false)
331-
{
325+
public function setSuperScript($pValue = false) {
332326
if (!is_bool($pValue)) {
333327
$pValue = false;
334328
}
@@ -342,8 +336,7 @@ public function setSuperScript($pValue = false)
342336
*
343337
* @return bool
344338
*/
345-
public function getSubScript()
346-
{
339+
public function getSubScript() {
347340
return $this->_subScript;
348341
}
349342

@@ -353,8 +346,7 @@ public function getSubScript()
353346
* @param bool $pValue
354347
* @return PHPWord_Style_Font
355348
*/
356-
public function setSubScript($pValue = false)
357-
{
349+
public function setSubScript($pValue = false) {
358350
if (!is_bool($pValue)) {
359351
$pValue = false;
360352
}
@@ -368,8 +360,7 @@ public function setSubScript($pValue = false)
368360
*
369361
* @return string
370362
*/
371-
public function getUnderline()
372-
{
363+
public function getUnderline() {
373364
return $this->_underline;
374365
}
375366

@@ -379,8 +370,7 @@ public function getUnderline()
379370
* @param string $pValue
380371
* @return PHPWord_Style_Font
381372
*/
382-
public function setUnderline($pValue = PHPWord_Style_Font::UNDERLINE_NONE)
383-
{
373+
public function setUnderline($pValue = PHPWord_Style_Font::UNDERLINE_NONE) {
384374
if ($pValue == '') {
385375
$pValue = PHPWord_Style_Font::UNDERLINE_NONE;
386376
}
@@ -393,8 +383,7 @@ public function setUnderline($pValue = PHPWord_Style_Font::UNDERLINE_NONE)
393383
*
394384
* @return bool
395385
*/
396-
public function getStrikethrough()
397-
{
386+
public function getStrikethrough() {
398387
return $this->_strikethrough;
399388
}
400389

@@ -404,8 +393,7 @@ public function getStrikethrough()
404393
* @param bool $pValue
405394
* @return PHPWord_Style_Font
406395
*/
407-
public function setStrikethrough($pValue = false)
408-
{
396+
public function setStrikethrough($pValue = false) {
409397
if (!is_bool($pValue)) {
410398
$pValue = false;
411399
}
@@ -418,8 +406,7 @@ public function setStrikethrough($pValue = false)
418406
*
419407
* @return string
420408
*/
421-
public function getColor()
422-
{
409+
public function getColor() {
423410
return $this->_color;
424411
}
425412

@@ -429,8 +416,7 @@ public function getColor()
429416
* @param string $pValue
430417
* @return PHPWord_Style_Font
431418
*/
432-
public function setColor($pValue = PHPWord::DEFAULT_FONT_COLOR)
433-
{
419+
public function setColor($pValue = PHPWord::DEFAULT_FONT_COLOR) {
434420
if (is_null($pValue) || $pValue == '') {
435421
$pValue = PHPWord::DEFAULT_FONT_COLOR;
436422
}
@@ -443,8 +429,7 @@ public function setColor($pValue = PHPWord::DEFAULT_FONT_COLOR)
443429
*
444430
* @return bool
445431
*/
446-
public function getFgColor()
447-
{
432+
public function getFgColor() {
448433
return $this->_fgColor;
449434
}
450435

@@ -454,8 +439,7 @@ public function getFgColor()
454439
* @param string $pValue
455440
* @return PHPWord_Style_Font
456441
*/
457-
public function setFgColor($pValue = null)
458-
{
442+
public function setFgColor($pValue = null) {
459443
$this->_fgColor = $pValue;
460444
return $this;
461445
}
@@ -465,8 +449,7 @@ public function setFgColor($pValue = null)
465449
*
466450
* @return string
467451
*/
468-
public function getStyleType()
469-
{
452+
public function getStyleType() {
470453
return $this->_type;
471454
}
472455

@@ -475,21 +458,18 @@ public function getStyleType()
475458
*
476459
* @return PHPWord_Style_Paragraph
477460
*/
478-
public function getParagraphStyle()
479-
{
461+
public function getParagraphStyle() {
480462
return $this->_paragraphStyle;
481463
}
482464

483-
484465
/**
485466
* Set the line height
486467
*
487468
* @param int|float|string $lineHeight
488469
* @return $this
489470
* @throws InvalidStyleException
490471
*/
491-
public function setLineHeight($lineHeight)
492-
{
472+
public function setLineHeight($lineHeight) {
493473
if (is_string($lineHeight)) {
494474
$lineHeight = floatval(preg_replace('/[^0-9\.\,]/', '', $lineHeight));
495475
}
@@ -506,8 +486,28 @@ public function setLineHeight($lineHeight)
506486
/**
507487
* @return int|float
508488
*/
509-
public function getLineHeight()
510-
{
489+
public function getLineHeight() {
511490
return $this->lineHeight;
512491
}
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+
}
513513
}

0 commit comments

Comments
 (0)