Beispiel #1
0
 /**
  * Read a FONT record
  */
 private function _readFont()
 {
     $length = $this->_GetInt2d($this->_data, $this->_pos + 2);
     $recordData = substr($this->_data, $this->_pos + 4, $length);
     // move stream pointer to next record
     $this->_pos += 4 + $length;
     if (!$this->_readDataOnly) {
         $objFont = new PHPExcel_Style_Font();
         // offset: 0; size: 2; height of the font (in twips = 1/20 of a point)
         $size = $this->_GetInt2d($recordData, 0);
         $objFont->setSize($size / 20);
         // offset: 2; size: 2; option flags
         // bit: 0; mask 0x0001; bold (redundant in BIFF5-BIFF8)
         // bit: 1; mask 0x0002; italic
         $isItalic = (0x2 & $this->_GetInt2d($recordData, 2)) >> 1;
         if ($isItalic) {
             $objFont->setItalic(true);
         }
         // bit: 2; mask 0x0004; underlined (redundant in BIFF5-BIFF8)
         // bit: 3; mask 0x0008; strike
         $isStrike = (0x8 & $this->_GetInt2d($recordData, 2)) >> 3;
         if ($isStrike) {
             $objFont->setStriketrough(true);
         }
         // offset: 4; size: 2; colour index
         $colorIndex = $this->_GetInt2d($recordData, 4);
         $objFont->colorIndex = $colorIndex;
         // offset: 6; size: 2; font weight
         $weight = $this->_GetInt2d($recordData, 6);
         switch ($weight) {
             case 0x2bc:
                 $objFont->setBold(true);
                 break;
         }
         // offset: 8; size: 2; escapement type
         $escapement = $this->_GetInt2d($recordData, 8);
         switch ($escapement) {
             case 0x1:
                 $objFont->setSuperScript(true);
                 break;
             case 0x2:
                 $objFont->setSubScript(true);
                 break;
         }
         // offset: 10; size: 1; underline type
         $underlineType = ord($recordData[10]);
         switch ($underlineType) {
             case 0x0:
                 break;
                 // no underline
             // no underline
             case 0x1:
                 $objFont->setUnderline(PHPExcel_Style_Font::UNDERLINE_SINGLE);
                 break;
             case 0x2:
                 $objFont->setUnderline(PHPExcel_Style_Font::UNDERLINE_DOUBLE);
                 break;
             case 0x21:
                 $objFont->setUnderline(PHPExcel_Style_Font::UNDERLINE_SINGLEACCOUNTING);
                 break;
             case 0x22:
                 $objFont->setUnderline(PHPExcel_Style_Font::UNDERLINE_DOUBLEACCOUNTING);
                 break;
         }
         // offset: 11; size: 1; font family
         // offset: 12; size: 1; character set
         // offset: 13; size: 1; not used
         // offset: 14; size: var; font name
         if ($this->_version == self::XLS_BIFF8) {
             $string = $this->_readUnicodeStringShort(substr($recordData, 14));
         } else {
             $string = $this->_readByteStringShort(substr($recordData, 14));
         }
         $objFont->setName($string['value']);
         $this->_objFonts[] = $objFont;
     }
 }