Source for file Font.php
Documentation is available at Font.php
* Copyright (c) 2006 - 2011 PHPExcel
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* @package PHPExcel_Style
* @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version 1.7.6, 2011-02-27
* @package PHPExcel_Style
* @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
const UNDERLINE_NONE = 'none';
const UNDERLINE_DOUBLE = 'double';
const UNDERLINE_DOUBLEACCOUNTING = 'doubleAccounting';
const UNDERLINE_SINGLE = 'single';
const UNDERLINE_SINGLEACCOUNTING = 'singleAccounting';
private $_name = 'Calibri';
private $_italic = false;
private $_superScript = false;
private $_subScript = false;
private $_underline = PHPExcel_Style_Font::UNDERLINE_NONE;
private $_strikethrough = false;
* @var PHPExcel_Style_Color
* @var _parentPropertyName string
private $_parentPropertyName;
* Parent. Only used for supervisor
* Create a new PHPExcel_Style_Font
$this->_isSupervisor = $isSupervisor;
// bind parent if we are a supervisor
* Bind parent. Only used for supervisor
* @param PHPExcel_Style $parent
* @return PHPExcel_Style_Font
$this->_parent = $parent;
* Is this a supervisor or a real style component?
return $this->_isSupervisor;
* Get the shared style component for the currently active cell in currently active sheet.
* Only used for style supervisor
* @return PHPExcel_Style_Font
* Get the currently active sheet. Only used for supervisor
* @return PHPExcel_Worksheet
* Get the currently active cell coordinate in currently active sheet.
* Only used for supervisor
* @return string E.g. 'A1'
* Get the currently active cell coordinate in currently active sheet.
* Only used for supervisor
* @return string E.g. 'A1'
* Build style array from subcomponents
return array('font' => $array);
* Apply styles from array
* $objPHPExcel->getActiveSheet()->getStyle('B2')->getFont()->applyFromArray(
* 'underline' => PHPExcel_Style_Font::UNDERLINE_DOUBLE,
* @param array $pStyles Array containing style information
* @return PHPExcel_Style_Font
if ($this->_isSupervisor) {
$this->getColor()->applyFromArray($pStyles['color']);
throw new Exception("Invalid style array passed.");
if ($this->_isSupervisor) {
* @return PHPExcel_Style_Font
public function setName($pValue = 'Calibri') {
if ($this->_isSupervisor) {
if ($this->_isSupervisor) {
* @return PHPExcel_Style_Font
public function setSize($pValue = 10) {
if ($this->_isSupervisor) {
if ($this->_isSupervisor) {
* @return PHPExcel_Style_Font
public function setBold($pValue = false) {
if ($this->_isSupervisor) {
if ($this->_isSupervisor) {
* @return PHPExcel_Style_Font
if ($this->_isSupervisor) {
$this->_italic = $pValue;
if ($this->_isSupervisor) {
return $this->_superScript;
* @return PHPExcel_Style_Font
if ($this->_isSupervisor) {
$styleArray = $this->getStyleArray(array('superScript' => $pValue));
$this->_superScript = $pValue;
$this->_subScript = !$pValue;
if ($this->_isSupervisor) {
return $this->_subScript;
* @return PHPExcel_Style_Font
if ($this->_isSupervisor) {
$styleArray = $this->getStyleArray(array('subScript' => $pValue));
$this->_subScript = $pValue;
$this->_superScript = !$pValue;
if ($this->_isSupervisor) {
return $this->_underline;
* @param string $pValue PHPExcel_Style_Font underline type
* @return PHPExcel_Style_Font
public function setUnderline($pValue = PHPExcel_Style_Font::UNDERLINE_NONE) {
if ($this->_isSupervisor) {
$styleArray = $this->getStyleArray(array('underline' => $pValue));
$this->_underline = $pValue;
* @deprecated Use getStrikethrough() instead.
* @deprecated Use setStrikethrough() instead.
* @return PHPExcel_Style_Font
if ($this->_isSupervisor) {
return $this->_strikethrough;
* @return PHPExcel_Style_Font
if ($this->_isSupervisor) {
$this->_strikethrough = $pValue;
* @return PHPExcel_Style_Color
* @param PHPExcel_Style_Color $pValue
* @return PHPExcel_Style_Font
public function setColor(PHPExcel_Style_Color $pValue = null) {
// make sure parameter is a real color and not a supervisor
$color = $pValue->getIsSupervisor() ? $pValue->getSharedComponent() : $pValue;
if ($this->_isSupervisor) {
$styleArray = $this->getColor()->getStyleArray(array('argb' => $color->getARGB()));
* @return string Hash code
if ($this->_isSupervisor) {
. ($this->_bold ? 't' : 'f')
. ($this->_italic ? 't' : 'f')
. ($this->_superScript ? 't' : 'f')
. ($this->_subScript ? 't' : 'f')
. ($this->_strikethrough ? 't' : 'f')
* Implement PHP __clone to create a deep clone, not just a shallow copy.
foreach ($vars as $key => $value) {
if ((is_object($value)) && ($key != '_parent')) {
$this->$key = clone $value;
|