Example #1
0
 /**
  * Get font style
  */
 public function testFont()
 {
     $oText = new Text(htmlspecialchars('text', ENT_COMPAT, 'UTF-8'), 'fontStyle');
     $this->assertEquals('fontStyle', $oText->getFontStyle());
     $oText->setFontStyle(array('bold' => true, 'italic' => true, 'size' => 16));
     $this->assertInstanceOf('PhpOffice\\PhpWord\\Style\\Font', $oText->getFontStyle());
 }
Example #2
0
 /**
  * Get font style
  */
 public function testFont()
 {
     $oText = new Text('text', 'fontStyle');
     $this->assertEquals($oText->getFontStyle(), 'fontStyle');
     $oText->setFontStyle(array('bold' => true, 'italic' => true, 'size' => 16));
     $this->assertInstanceOf('PhpOffice\\PhpWord\\Style\\Font', $oText->getFontStyle());
 }
Example #3
0
 /**
  * Get style of individual element
  *
  * @param \PhpOffice\PhpWord\Element\Text $element
  * @param int $paragraphStyleCount
  * @param int $fontStyleCount
  */
 private function getElementStyle(&$element, &$paragraphStyleCount, &$fontStyleCount)
 {
     $fontStyle = $element->getFontStyle();
     $paragraphStyle = $element->getParagraphStyle();
     $phpWord = $this->getParentWriter()->getPhpWord();
     // Font
     if ($fontStyle instanceof Font) {
         $fontStyleCount++;
         $style = $phpWord->addFontStyle("T{$fontStyleCount}", $fontStyle);
         $style->setAuto();
         $element->setFontStyle("T{$fontStyleCount}");
         // Paragraph
     } elseif ($paragraphStyle instanceof Paragraph) {
         $paragraphStyleCount++;
         $style = $phpWord->addParagraphStyle("P{$paragraphStyleCount}", array());
         $style->setAuto();
         $element->setParagraphStyle("P{$paragraphStyleCount}");
     }
 }