Exemplo n.º 1
0
 /**
  * gets rtf code of font
  *
  * @return string rtf code
  */
 public function getContent()
 {
     $content = '';
     if ($this->_size > 0) {
         $content .= '\\fs' . $this->_size * 2 . ' ';
     }
     if ($this->_fontFamily && $this->_fontTable) {
         $fontIndex = $this->_fontTable->getFontIndex($this->_fontFamily);
         if ($fontIndex !== false) {
             $content .= '\\f' . $fontIndex . ' ';
         }
     }
     if ($this->_color && $this->_colorTable) {
         $colorIndex = $this->_colorTable->getColorIndex($this->_color);
         if ($colorIndex !== false) {
             $content .= '\\cf' . $colorIndex . ' ';
         }
     }
     if ($this->_backgroundColor && $this->_colorTable) {
         $colorIndex = $this->_colorTable->getColorIndex($this->_backgroundColor);
         if ($colorIndex !== false) {
             $content .= '\\chcbpat' . $colorIndex . ' ';
         }
     }
     if ($this->_isBold) {
         $content .= '\\b ';
     }
     if ($this->_isItalic) {
         $content .= '\\i ';
     }
     if ($this->_isUnderlined) {
         $content .= '\\ul ';
     }
     if ($this->_animation) {
         $content .= '\\animtext' . $this->_animation;
     }
     if ($this->_isStriked) {
         $content .= '\\strike ' . $this->_animation;
     } elseif ($this->_isDoubleStriked) {
         $content .= '\\striked1 ' . $this->_animation;
     }
     return $content;
 }
Exemplo n.º 2
0
 /**
  * @dataProvider provideGetFontIndex
  * @param   PHPRtfLite_DocHead_FontTable    $fontTable
  * @param   string                          $font
  * @param   integer                         $fontIndex
  */
 public function testGetFontIndex(PHPRtfLite_DocHead_FontTable $fontTable, $font, $fontIndex)
 {
     $fontTable->add($font);
     $this->assertEquals($fontIndex, $fontTable->getFontIndex($font));
 }