Skip to content

Commit eb6b44e

Browse files
committed
Use constant instead of hardcoded 'Arial' name.
1 parent b0a2470 commit eb6b44e

File tree

6 files changed

+22
-19
lines changed

6 files changed

+22
-19
lines changed

Classes/PHPWord.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@
3939
class PHPWord
4040
{
4141

42+
const DEFAULT_FONT_NAME = 'Arial';
43+
const DEFAULT_FONT_SIZE = 20;
44+
4245
/**
4346
* Document properties
4447
*
@@ -74,8 +77,8 @@ class PHPWord
7477
public function __construct()
7578
{
7679
$this->_properties = new PHPWord_DocumentProperties();
77-
$this->_defaultFontName = 'Arial';
78-
$this->_defaultFontSize = 20;
80+
$this->_defaultFontName = PHPWord::DEFAULT_FONT_NAME;
81+
$this->_defaultFontSize = PHPWord::DEFAULT_FONT_SIZE;
7982
}
8083

8184
/**

Classes/PHPWord/Style/Font.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,8 @@ class PHPWord_Style_Font
9494
public function __construct($type = 'text', $styleParagraph = null)
9595
{
9696
$this->_type = $type;
97-
$this->_name = 'Arial';
98-
$this->_size = 20;
97+
$this->_name = PHPWord::DEFAULT_FONT_NAME;
98+
$this->_size = PHPWord::DEFAULT_FONT_SIZE;
9999
$this->_bold = false;
100100
$this->_italic = false;
101101
$this->_superScript = false;
@@ -132,10 +132,10 @@ public function setStyleValue($key, $value)
132132
$this->$key = $value;
133133
}
134134

135-
public function setName($pValue = 'Arial')
135+
public function setName($pValue = PHPWord::DEFAULT_FONT_NAME)
136136
{
137137
if ($pValue == '') {
138-
$pValue = 'Arial';
138+
$pValue = PHPWord::DEFAULT_FONT_NAME;
139139
}
140140
$this->_name = $pValue;
141141
return $this;
@@ -146,10 +146,10 @@ public function getSize()
146146
return $this->_size;
147147
}
148148

149-
public function setSize($pValue = 20)
149+
public function setSize($pValue = PHPWord::DEFAULT_FONT_SIZE)
150150
{
151151
if ($pValue == '') {
152-
$pValue = 20;
152+
$pValue = PHPWord::DEFAULT_FONT_SIZE;
153153
}
154154
$this->_size = ($pValue * 2);
155155
return $this;

Classes/PHPWord/Writer/ODText/Content.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -145,10 +145,10 @@ public function writeContent(PHPWord $pPHPWord = null)
145145
}
146146
}
147147
}
148-
if (!in_array('Arial', $arrFonts)) {
148+
if (!in_array(PHPWord::DEFAULT_FONT_NAME, $arrFonts)) {
149149
$objWriter->startElement('style:font-face');
150-
$objWriter->writeAttribute('style:name', 'Arial');
151-
$objWriter->writeAttribute('svg:font-family', 'Arial');
150+
$objWriter->writeAttribute('style:name', PHPWord::DEFAULT_FONT_NAME);
151+
$objWriter->writeAttribute('svg:font-family', PHPWord::DEFAULT_FONT_NAME);
152152
$objWriter->endElement();
153153
}
154154
}

Classes/PHPWord/Writer/ODText/Styles.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,10 @@ public function writeStyles(PHPWord $pPHPWord = null)
104104
}
105105
}
106106
}
107-
if (!in_array('Arial', $arrFonts)) {
107+
if (!in_array(PHPWord::DEFAULT_FONT_NAME, $arrFonts)) {
108108
$objWriter->startElement('style:font-face');
109-
$objWriter->writeAttribute('style:name', 'Arial');
110-
$objWriter->writeAttribute('svg:font-family', 'Arial');
109+
$objWriter->writeAttribute('style:name', PHPWord::DEFAULT_FONT_NAME);
110+
$objWriter->writeAttribute('svg:font-family', PHPWord::DEFAULT_FONT_NAME);
111111
$objWriter->endElement();
112112
}
113113
$objWriter->endElement();
@@ -132,7 +132,7 @@ public function writeStyles(PHPWord $pPHPWord = null)
132132
// style:text-properties
133133
$objWriter->startElement('style:text-properties');
134134
$objWriter->writeAttribute('style:use-window-font-color', 'true');
135-
$objWriter->writeAttribute('style:font-name', 'Arial');
135+
$objWriter->writeAttribute('style:font-name', PHPWord::DEFAULT_FONT_NAME);
136136
$objWriter->writeAttribute('fo:font-size', '10pt');
137137
$objWriter->writeAttribute('fo:language', 'fr');
138138
$objWriter->writeAttribute('fo:country', 'FR');

Classes/PHPWord/Writer/RTF.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,8 +191,8 @@ private function _getDataFont()
191191
$pPHPWord = $this->_document;
192192

193193
$arrFonts = array();
194-
// Default font : Arial
195-
$arrFonts[] = 'Arial';
194+
// Default font : PHPWord::DEFAULT_FONT_NAME
195+
$arrFonts[] = PHPWord::DEFAULT_FONT_NAME;
196196
// PHPWord object : $this->_document
197197

198198
// Browse styles

Classes/PHPWord/Writer/Word2007/Base.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ protected function _writeTextStyle(PHPWord_Shared_XMLWriter $objWriter = null, P
334334
$objWriter->startElement('w:rPr');
335335

336336
// Font
337-
if ($font != 'Arial') {
337+
if ($font != PHPWord::DEFAULT_FONT_NAME) {
338338
$objWriter->startElement('w:rFonts');
339339
$objWriter->writeAttribute('w:ascii', $font);
340340
$objWriter->writeAttribute('w:hAnsi', $font);
@@ -350,7 +350,7 @@ protected function _writeTextStyle(PHPWord_Shared_XMLWriter $objWriter = null, P
350350
}
351351

352352
// Size
353-
if ($size != 20) {
353+
if ($size != PHPWord::DEFAULT_FONT_SIZE) {
354354
$objWriter->startElement('w:sz');
355355
$objWriter->writeAttribute('w:val', $size);
356356
$objWriter->endElement();

0 commit comments

Comments
 (0)