123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995 |
- <?php
- /**
- * This file is part of PHPWord - A pure PHP library for reading and writing
- * word processing documents.
- *
- * PHPWord is free software distributed under the terms of the GNU Lesser
- * General Public License version 3 as published by the Free Software Foundation.
- *
- * For the full copyright and license information, please read the LICENSE
- * file that was distributed with this source code. For the full list of
- * contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
- *
- * @see https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2018 PHPWord contributors
- * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
- */
- namespace PhpOffice\PhpWord\Style;
- /**
- * Font style
- */
- class Font extends AbstractStyle
- {
- /**
- * Underline types
- *
- * @const string
- */
- const UNDERLINE_NONE = 'none';
- const UNDERLINE_DASH = 'dash';
- const UNDERLINE_DASHHEAVY = 'dashHeavy';
- const UNDERLINE_DASHLONG = 'dashLong';
- const UNDERLINE_DASHLONGHEAVY = 'dashLongHeavy';
- const UNDERLINE_DOUBLE = 'dbl';
- /**
- * @deprecated use UNDERLINE_DOTHASH instead, TODO remove in version 1.0
- */
- const UNDERLINE_DOTHASH = 'dotDash'; // Incorrect spelling, for backwards compatibility
- /**
- * @deprecated use UNDERLINE_DOTDASHHEAVY instead, TODO remove in version 1.0
- */
- const UNDERLINE_DOTHASHHEAVY = 'dotDashHeavy'; // Incorrect spelling, for backwards compatibility
- const UNDERLINE_DOTDASH = 'dotDash';
- const UNDERLINE_DOTDASHHEAVY = 'dotDashHeavy';
- const UNDERLINE_DOTDOTDASH = 'dotDotDash';
- const UNDERLINE_DOTDOTDASHHEAVY = 'dotDotDashHeavy';
- const UNDERLINE_DOTTED = 'dotted';
- const UNDERLINE_DOTTEDHEAVY = 'dottedHeavy';
- const UNDERLINE_HEAVY = 'heavy';
- const UNDERLINE_SINGLE = 'single';
- const UNDERLINE_WAVY = 'wavy';
- const UNDERLINE_WAVYDOUBLE = 'wavyDbl';
- const UNDERLINE_WAVYHEAVY = 'wavyHeavy';
- const UNDERLINE_WORDS = 'words';
- /**
- * Foreground colors
- *
- * @const string
- */
- const FGCOLOR_YELLOW = 'yellow';
- const FGCOLOR_LIGHTGREEN = 'green';
- const FGCOLOR_CYAN = 'cyan';
- const FGCOLOR_MAGENTA = 'magenta';
- const FGCOLOR_BLUE = 'blue';
- const FGCOLOR_RED = 'red';
- const FGCOLOR_DARKBLUE = 'darkBlue';
- const FGCOLOR_DARKCYAN = 'darkCyan';
- const FGCOLOR_DARKGREEN = 'darkGreen';
- const FGCOLOR_DARKMAGENTA = 'darkMagenta';
- const FGCOLOR_DARKRED = 'darkRed';
- const FGCOLOR_DARKYELLOW = 'darkYellow';
- const FGCOLOR_DARKGRAY = 'darkGray';
- const FGCOLOR_LIGHTGRAY = 'lightGray';
- const FGCOLOR_BLACK = 'black';
- /**
- * Aliases
- *
- * @var array
- */
- protected $aliases = array('line-height' => 'lineHeight', 'letter-spacing' => 'spacing');
- /**
- * Font style type
- *
- * @var string
- */
- private $type;
- /**
- * Font name
- *
- * @var string
- */
- private $name;
- /**
- * Font Content Type
- *
- * @var string
- */
- private $hint;
- /**
- * Font size
- *
- * @var int|float
- */
- private $size;
- /**
- * Font color
- *
- * @var string
- */
- private $color;
- /**
- * Bold
- *
- * @var bool
- */
- private $bold;
- /**
- * Italic
- *
- * @var bool
- */
- private $italic;
- /**
- * Undeline
- *
- * @var string
- */
- private $underline = self::UNDERLINE_NONE;
- /**
- * Superscript
- *
- * @var bool
- */
- private $superScript = false;
- /**
- * Subscript
- *
- * @var bool
- */
- private $subScript = false;
- /**
- * Strikethrough
- *
- * @var bool
- */
- private $strikethrough;
- /**
- * Double strikethrough
- *
- * @var bool
- */
- private $doubleStrikethrough;
- /**
- * Small caps
- *
- * @var bool
- * @see http://www.schemacentral.com/sc/ooxml/e-w_smallCaps-1.html
- */
- private $smallCaps;
- /**
- * All caps
- *
- * @var bool
- * @see http://www.schemacentral.com/sc/ooxml/e-w_caps-1.html
- */
- private $allCaps;
- /**
- * Foreground/highlight
- *
- * @var string
- */
- private $fgColor;
- /**
- * Expanded/compressed text: 0-600 (percent)
- *
- * @var int
- * @since 0.12.0
- * @see http://www.schemacentral.com/sc/ooxml/e-w_w-1.html
- */
- private $scale;
- /**
- * Character spacing adjustment: twip
- *
- * @var int|float
- * @since 0.12.0
- * @see http://www.schemacentral.com/sc/ooxml/e-w_spacing-2.html
- */
- private $spacing;
- /**
- * Font kerning: halfpoint
- *
- * @var int|float
- * @since 0.12.0
- * @see http://www.schemacentral.com/sc/ooxml/e-w_kern-1.html
- */
- private $kerning;
- /**
- * Paragraph style
- *
- * @var \PhpOffice\PhpWord\Style\Paragraph
- */
- private $paragraph;
- /**
- * Shading
- *
- * @var \PhpOffice\PhpWord\Style\Shading
- */
- private $shading;
- /**
- * Right to left languages
- *
- * @var bool
- */
- private $rtl;
- /**
- * noProof (disables AutoCorrect)
- *
- * @var bool
- * http://www.datypic.com/sc/ooxml/e-w_noProof-1.html
- */
- private $noProof;
- /**
- * Languages
- *
- * @var \PhpOffice\PhpWord\Style\Language
- */
- private $lang;
- /**
- * Hidden text
- *
- * @var bool
- * @see http://www.datypic.com/sc/ooxml/e-w_vanish-1.html
- */
- private $hidden;
- /**
- * Vertically Raised or Lowered Text
- *
- * @var int Signed Half-Point Measurement
- * @see http://www.datypic.com/sc/ooxml/e-w_position-1.html
- */
- private $position;
- /**
- * Create new font style
- *
- * @param string $type Type of font
- * @param array|string|\PhpOffice\PhpWord\Style\AbstractStyle $paragraph Paragraph styles definition
- */
- public function __construct($type = 'text', $paragraph = null)
- {
- $this->type = $type;
- $this->setParagraph($paragraph);
- }
- /**
- * Get style values
- *
- * @return array
- * @since 0.12.0
- */
- public function getStyleValues()
- {
- $styles = array(
- 'name' => $this->getStyleName(),
- 'basic' => array(
- 'name' => $this->getName(),
- 'size' => $this->getSize(),
- 'color' => $this->getColor(),
- 'hint' => $this->getHint(),
- ),
- 'style' => array(
- 'bold' => $this->isBold(),
- 'italic' => $this->isItalic(),
- 'underline' => $this->getUnderline(),
- 'strike' => $this->isStrikethrough(),
- 'dStrike' => $this->isDoubleStrikethrough(),
- 'super' => $this->isSuperScript(),
- 'sub' => $this->isSubScript(),
- 'smallCaps' => $this->isSmallCaps(),
- 'allCaps' => $this->isAllCaps(),
- 'fgColor' => $this->getFgColor(),
- 'hidden' => $this->isHidden(),
- ),
- 'spacing' => array(
- 'scale' => $this->getScale(),
- 'spacing' => $this->getSpacing(),
- 'kerning' => $this->getKerning(),
- 'position' => $this->getPosition(),
- ),
- 'paragraph' => $this->getParagraph(),
- 'rtl' => $this->isRTL(),
- 'shading' => $this->getShading(),
- 'lang' => $this->getLang(),
- );
- return $styles;
- }
- /**
- * Get style type
- *
- * @return string
- */
- public function getStyleType()
- {
- return $this->type;
- }
- /**
- * Get font name
- *
- * @return string
- */
- public function getName()
- {
- return $this->name;
- }
- /**
- * Set font name
- *
- * @param string $value
- * @return self
- */
- public function setName($value = null)
- {
- $this->name = $value;
- return $this;
- }
- /**
- * Get Font Content Type
- *
- * @return string
- */
- public function getHint()
- {
- return $this->hint;
- }
- /**
- * Set Font Content Type
- *
- * @param string $value
- * @return self
- */
- public function setHint($value = null)
- {
- $this->hint = $value;
- return $this;
- }
- /**
- * Get font size
- *
- * @return int|float
- */
- public function getSize()
- {
- return $this->size;
- }
- /**
- * Set font size
- *
- * @param int|float $value
- * @return self
- */
- public function setSize($value = null)
- {
- $this->size = $this->setNumericVal($value, $this->size);
- return $this;
- }
- /**
- * Get font color
- *
- * @return string
- */
- public function getColor()
- {
- return $this->color;
- }
- /**
- * Set font color
- *
- * @param string $value
- * @return self
- */
- public function setColor($value = null)
- {
- $this->color = $value;
- return $this;
- }
- /**
- * Get bold
- *
- * @return bool
- */
- public function isBold()
- {
- return $this->bold;
- }
- /**
- * Set bold
- *
- * @param bool $value
- * @return self
- */
- public function setBold($value = true)
- {
- $this->bold = $this->setBoolVal($value, $this->bold);
- return $this;
- }
- /**
- * Get italic
- *
- * @return bool
- */
- public function isItalic()
- {
- return $this->italic;
- }
- /**
- * Set italic
- *
- * @param bool $value
- * @return self
- */
- public function setItalic($value = true)
- {
- $this->italic = $this->setBoolVal($value, $this->italic);
- return $this;
- }
- /**
- * Get underline
- *
- * @return string
- */
- public function getUnderline()
- {
- return $this->underline;
- }
- /**
- * Set underline
- *
- * @param string $value
- * @return self
- */
- public function setUnderline($value = self::UNDERLINE_NONE)
- {
- $this->underline = $this->setNonEmptyVal($value, self::UNDERLINE_NONE);
- return $this;
- }
- /**
- * Get superscript
- *
- * @return bool
- */
- public function isSuperScript()
- {
- return $this->superScript;
- }
- /**
- * Set superscript
- *
- * @param bool $value
- * @return self
- */
- public function setSuperScript($value = true)
- {
- return $this->setPairedVal($this->superScript, $this->subScript, $value);
- }
- /**
- * Get subscript
- *
- * @return bool
- */
- public function isSubScript()
- {
- return $this->subScript;
- }
- /**
- * Set subscript
- *
- * @param bool $value
- * @return self
- */
- public function setSubScript($value = true)
- {
- return $this->setPairedVal($this->subScript, $this->superScript, $value);
- }
- /**
- * Get strikethrough
- *
- * @return bool
- */
- public function isStrikethrough()
- {
- return $this->strikethrough;
- }
- /**
- * Set strikethrough
- *
- * @param bool $value
- * @return self
- */
- public function setStrikethrough($value = true)
- {
- return $this->setPairedVal($this->strikethrough, $this->doubleStrikethrough, $value);
- }
- /**
- * Get double strikethrough
- *
- * @return bool
- */
- public function isDoubleStrikethrough()
- {
- return $this->doubleStrikethrough;
- }
- /**
- * Set double strikethrough
- *
- * @param bool $value
- * @return self
- */
- public function setDoubleStrikethrough($value = true)
- {
- return $this->setPairedVal($this->doubleStrikethrough, $this->strikethrough, $value);
- }
- /**
- * Get small caps
- *
- * @return bool
- */
- public function isSmallCaps()
- {
- return $this->smallCaps;
- }
- /**
- * Set small caps
- *
- * @param bool $value
- * @return self
- */
- public function setSmallCaps($value = true)
- {
- return $this->setPairedVal($this->smallCaps, $this->allCaps, $value);
- }
- /**
- * Get all caps
- *
- * @return bool
- */
- public function isAllCaps()
- {
- return $this->allCaps;
- }
- /**
- * Set all caps
- *
- * @param bool $value
- * @return self
- */
- public function setAllCaps($value = true)
- {
- return $this->setPairedVal($this->allCaps, $this->smallCaps, $value);
- }
- /**
- * Get foreground/highlight color
- *
- * @return string
- */
- public function getFgColor()
- {
- return $this->fgColor;
- }
- /**
- * Set foreground/highlight color
- *
- * @param string $value
- * @return self
- */
- public function setFgColor($value = null)
- {
- $this->fgColor = $value;
- return $this;
- }
- /**
- * Get background
- *
- * @return string
- */
- public function getBgColor()
- {
- return $this->getChildStyleValue($this->shading, 'fill');
- }
- /**
- * Set background
- *
- * @param string $value
- * @return \PhpOffice\PhpWord\Style\Table
- */
- public function setBgColor($value = null)
- {
- $this->setShading(array('fill' => $value));
- }
- /**
- * Get scale
- *
- * @return int
- */
- public function getScale()
- {
- return $this->scale;
- }
- /**
- * Set scale
- *
- * @param int $value
- * @return self
- */
- public function setScale($value = null)
- {
- $this->scale = $this->setIntVal($value, null);
- return $this;
- }
- /**
- * Get font spacing
- *
- * @return int|float
- */
- public function getSpacing()
- {
- return $this->spacing;
- }
- /**
- * Set font spacing
- *
- * @param int|float $value
- * @return self
- */
- public function setSpacing($value = null)
- {
- $this->spacing = $this->setNumericVal($value, null);
- return $this;
- }
- /**
- * Get font kerning
- *
- * @return int|float
- */
- public function getKerning()
- {
- return $this->kerning;
- }
- /**
- * Set font kerning
- *
- * @param int|float $value
- * @return self
- */
- public function setKerning($value = null)
- {
- $this->kerning = $this->setNumericVal($value, null);
- return $this;
- }
- /**
- * Get noProof (disables autocorrect)
- *
- * @return bool
- */
- public function isNoProof()
- {
- return $this->noProof;
- }
- /**
- * Set noProof (disables autocorrect)
- *
- * @param bool $value
- * @return $this
- */
- public function setNoProof($value = false)
- {
- $this->noProof = $value;
- return $this;
- }
- /**
- * Get line height
- *
- * @return int|float
- */
- public function getLineHeight()
- {
- return $this->getParagraph()->getLineHeight();
- }
- /**
- * Set lineheight
- *
- * @param int|float|string $value
- * @return self
- */
- public function setLineHeight($value)
- {
- $this->setParagraph(array('lineHeight' => $value));
- return $this;
- }
- /**
- * Get paragraph style
- *
- * @return \PhpOffice\PhpWord\Style\Paragraph
- */
- public function getParagraph()
- {
- return $this->paragraph;
- }
- /**
- * Set Paragraph
- *
- * @param mixed $value
- * @return self
- */
- public function setParagraph($value = null)
- {
- $this->setObjectVal($value, 'Paragraph', $this->paragraph);
- return $this;
- }
- /**
- * Get rtl
- *
- * @return bool
- */
- public function isRTL()
- {
- return $this->rtl;
- }
- /**
- * Set rtl
- *
- * @param bool $value
- * @return self
- */
- public function setRTL($value = true)
- {
- $this->rtl = $this->setBoolVal($value, $this->rtl);
- return $this;
- }
- /**
- * Get shading
- *
- * @return \PhpOffice\PhpWord\Style\Shading
- */
- public function getShading()
- {
- return $this->shading;
- }
- /**
- * Set shading
- *
- * @param mixed $value
- * @return self
- */
- public function setShading($value = null)
- {
- $this->setObjectVal($value, 'Shading', $this->shading);
- return $this;
- }
- /**
- * Get language
- *
- * @return \PhpOffice\PhpWord\Style\Language
- */
- public function getLang()
- {
- return $this->lang;
- }
- /**
- * Set language
- *
- * @param mixed $value
- * @return self
- */
- public function setLang($value = null)
- {
- if (is_string($value) && $value != '') {
- $value = new Language($value);
- }
- $this->setObjectVal($value, 'Language', $this->lang);
- return $this;
- }
- /**
- * Get bold
- *
- * @deprecated 0.10.0
- *
- * @codeCoverageIgnore
- */
- public function getBold()
- {
- return $this->isBold();
- }
- /**
- * Get italic
- *
- * @deprecated 0.10.0
- *
- * @codeCoverageIgnore
- */
- public function getItalic()
- {
- return $this->isItalic();
- }
- /**
- * Get superscript
- *
- * @deprecated 0.10.0
- *
- * @codeCoverageIgnore
- */
- public function getSuperScript()
- {
- return $this->isSuperScript();
- }
- /**
- * Get subscript
- *
- * @deprecated 0.10.0
- *
- * @codeCoverageIgnore
- */
- public function getSubScript()
- {
- return $this->isSubScript();
- }
- /**
- * Get strikethrough
- *
- * @deprecated 0.10.0
- *
- * @codeCoverageIgnore
- */
- public function getStrikethrough()
- {
- return $this->isStrikethrough();
- }
- /**
- * Get paragraph style
- *
- * @deprecated 0.11.0
- *
- * @codeCoverageIgnore
- */
- public function getParagraphStyle()
- {
- return $this->getParagraph();
- }
- /**
- * Get hidden text
- *
- * @return bool
- */
- public function isHidden()
- {
- return $this->hidden;
- }
- /**
- * Set hidden text
- *
- * @param bool $value
- * @return self
- */
- public function setHidden($value = true)
- {
- $this->hidden = $this->setBoolVal($value, $this->hidden);
- return $this;
- }
- /**
- * Get position
- *
- * @return int
- */
- public function getPosition()
- {
- return $this->position;
- }
- /**
- * Set position
- *
- * @param int $value
- * @return self
- */
- public function setPosition($value = null)
- {
- $this->position = $this->setIntVal($value, null);
- return $this;
- }
- }
|