diff --git a/Classes/PHPWord.php b/Classes/PHPWord.php index 3879d7cd..51b37366 100755 --- a/Classes/PHPWord.php +++ b/Classes/PHPWord.php @@ -39,6 +39,9 @@ if (!defined('PHPWORD_BASE_PATH')) { class PHPWord { + const DEFAULT_FONT_NAME = 'Arial'; + const DEFAULT_FONT_SIZE = 20; + /** * Document properties * @@ -74,8 +77,8 @@ class PHPWord public function __construct() { $this->_properties = new PHPWord_DocumentProperties(); - $this->_defaultFontName = 'Arial'; - $this->_defaultFontSize = 20; + $this->_defaultFontName = PHPWord::DEFAULT_FONT_NAME; + $this->_defaultFontSize = PHPWord::DEFAULT_FONT_SIZE; } /** diff --git a/Classes/PHPWord/Style/Font.php b/Classes/PHPWord/Style/Font.php index eafc10b7..293d7e35 100755 --- a/Classes/PHPWord/Style/Font.php +++ b/Classes/PHPWord/Style/Font.php @@ -94,8 +94,8 @@ class PHPWord_Style_Font public function __construct($type = 'text', $styleParagraph = null) { $this->_type = $type; - $this->_name = 'Arial'; - $this->_size = 20; + $this->_name = PHPWord::DEFAULT_FONT_NAME; + $this->_size = PHPWord::DEFAULT_FONT_SIZE; $this->_bold = false; $this->_italic = false; $this->_superScript = false; @@ -132,10 +132,10 @@ class PHPWord_Style_Font $this->$key = $value; } - public function setName($pValue = 'Arial') + public function setName($pValue = PHPWord::DEFAULT_FONT_NAME) { if ($pValue == '') { - $pValue = 'Arial'; + $pValue = PHPWord::DEFAULT_FONT_NAME; } $this->_name = $pValue; return $this; @@ -146,10 +146,10 @@ class PHPWord_Style_Font return $this->_size; } - public function setSize($pValue = 20) + public function setSize($pValue = PHPWord::DEFAULT_FONT_SIZE) { if ($pValue == '') { - $pValue = 20; + $pValue = PHPWord::DEFAULT_FONT_SIZE; } $this->_size = ($pValue * 2); return $this; diff --git a/Classes/PHPWord/Writer/ODText/Content.php b/Classes/PHPWord/Writer/ODText/Content.php index 69ba3bef..f8784e10 100755 --- a/Classes/PHPWord/Writer/ODText/Content.php +++ b/Classes/PHPWord/Writer/ODText/Content.php @@ -145,10 +145,10 @@ class PHPWord_Writer_ODText_Content extends PHPWord_Writer_ODText_WriterPart } } } - if (!in_array('Arial', $arrFonts)) { + if (!in_array(PHPWord::DEFAULT_FONT_NAME, $arrFonts)) { $objWriter->startElement('style:font-face'); - $objWriter->writeAttribute('style:name', 'Arial'); - $objWriter->writeAttribute('svg:font-family', 'Arial'); + $objWriter->writeAttribute('style:name', PHPWord::DEFAULT_FONT_NAME); + $objWriter->writeAttribute('svg:font-family', PHPWord::DEFAULT_FONT_NAME); $objWriter->endElement(); } } diff --git a/Classes/PHPWord/Writer/ODText/Styles.php b/Classes/PHPWord/Writer/ODText/Styles.php index 2ec591ae..7830db78 100755 --- a/Classes/PHPWord/Writer/ODText/Styles.php +++ b/Classes/PHPWord/Writer/ODText/Styles.php @@ -104,10 +104,10 @@ class PHPWord_Writer_ODText_Styles extends PHPWord_Writer_ODText_WriterPart } } } - if (!in_array('Arial', $arrFonts)) { + if (!in_array(PHPWord::DEFAULT_FONT_NAME, $arrFonts)) { $objWriter->startElement('style:font-face'); - $objWriter->writeAttribute('style:name', 'Arial'); - $objWriter->writeAttribute('svg:font-family', 'Arial'); + $objWriter->writeAttribute('style:name', PHPWord::DEFAULT_FONT_NAME); + $objWriter->writeAttribute('svg:font-family', PHPWord::DEFAULT_FONT_NAME); $objWriter->endElement(); } $objWriter->endElement(); @@ -132,7 +132,7 @@ class PHPWord_Writer_ODText_Styles extends PHPWord_Writer_ODText_WriterPart // style:text-properties $objWriter->startElement('style:text-properties'); $objWriter->writeAttribute('style:use-window-font-color', 'true'); - $objWriter->writeAttribute('style:font-name', 'Arial'); + $objWriter->writeAttribute('style:font-name', PHPWord::DEFAULT_FONT_NAME); $objWriter->writeAttribute('fo:font-size', '10pt'); $objWriter->writeAttribute('fo:language', 'fr'); $objWriter->writeAttribute('fo:country', 'FR'); diff --git a/Classes/PHPWord/Writer/RTF.php b/Classes/PHPWord/Writer/RTF.php index 24f0157e..3f5b73ee 100755 --- a/Classes/PHPWord/Writer/RTF.php +++ b/Classes/PHPWord/Writer/RTF.php @@ -191,8 +191,8 @@ class PHPWord_Writer_RTF implements PHPWord_Writer_IWriter $pPHPWord = $this->_document; $arrFonts = array(); - // Default font : Arial - $arrFonts[] = 'Arial'; + // Default font : PHPWord::DEFAULT_FONT_NAME + $arrFonts[] = PHPWord::DEFAULT_FONT_NAME; // PHPWord object : $this->_document // Browse styles diff --git a/Classes/PHPWord/Writer/Word2007/Base.php b/Classes/PHPWord/Writer/Word2007/Base.php index 9ffbe59c..aedd4f50 100755 --- a/Classes/PHPWord/Writer/Word2007/Base.php +++ b/Classes/PHPWord/Writer/Word2007/Base.php @@ -334,7 +334,7 @@ class PHPWord_Writer_Word2007_Base extends PHPWord_Writer_Word2007_WriterPart $objWriter->startElement('w:rPr'); // Font - if ($font != 'Arial') { + if ($font != PHPWord::DEFAULT_FONT_NAME) { $objWriter->startElement('w:rFonts'); $objWriter->writeAttribute('w:ascii', $font); $objWriter->writeAttribute('w:hAnsi', $font); @@ -350,7 +350,7 @@ class PHPWord_Writer_Word2007_Base extends PHPWord_Writer_Word2007_WriterPart } // Size - if ($size != 20) { + if ($size != PHPWord::DEFAULT_FONT_SIZE) { $objWriter->startElement('w:sz'); $objWriter->writeAttribute('w:val', $size); $objWriter->endElement();