You are here

private function PHPExcel_Reader_Excel5::_readFont in Loft Data Grids 6.2

Same name and namespace in other branches
  1. 7.2 vendor/phpoffice/phpexcel/Classes/PHPExcel/Reader/Excel5.php \PHPExcel_Reader_Excel5::_readFont()

* Read a FONT record

1 call to PHPExcel_Reader_Excel5::_readFont()
PHPExcel_Reader_Excel5::load in vendor/phpoffice/phpexcel/Classes/PHPExcel/Reader/Excel5.php
* Loads PHPExcel from file * *

File

vendor/phpoffice/phpexcel/Classes/PHPExcel/Reader/Excel5.php, line 1872

Class

PHPExcel_Reader_Excel5
PHPExcel_Reader_Excel5

Code

private function _readFont() {
  $length = self::_GetInt2d($this->_data, $this->_pos + 2);
  $recordData = $this
    ->_readRecordData($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 = self::_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 & self::_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 & self::_GetInt2d($recordData, 2)) >> 3;
    if ($isStrike) {
      $objFont
        ->setStrikethrough(true);
    }

    // offset: 4; size: 2; colour index
    $colorIndex = self::_GetInt2d($recordData, 4);
    $objFont->colorIndex = $colorIndex;

    // offset: 6; size: 2; font weight
    $weight = self::_GetInt2d($recordData, 6);
    switch ($weight) {
      case 0x2bc:
        $objFont
          ->setBold(true);
        break;
    }

    // offset: 8; size: 2; escapement type
    $escapement = self::_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
      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 = self::_readUnicodeStringShort(substr($recordData, 14));
    }
    else {
      $string = $this
        ->_readByteStringShort(substr($recordData, 14));
    }
    $objFont
      ->setName($string['value']);
    $this->_objFonts[] = $objFont;
  }
}