Use constant instead of hardcoded 'Arial' name.
This commit is contained in:
parent
b0a24703f3
commit
eb6b44ef85
|
|
@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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');
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
Loading…
Reference in New Issue