예제 #1
0
 /**
  * Get post data
  */
 protected function getPostData()
 {
     $this->offset = $this->fdt['table']['post']['offset'];
     $this->offset += 4;
     // skip Format Type
     $this->fdt['italicAngle'] = $this->fbyte->getFixed($this->offset);
     $this->offset += 4;
     $this->fdt['underlinePosition'] = round($this->fbyte->getFWord($this->offset) * $this->fdt['urk']);
     $this->offset += 2;
     $this->fdt['underlineThickness'] = round($this->fbyte->getFWord($this->offset) * $this->fdt['urk']);
     $this->offset += 2;
     $isFixedPitch = $this->fbyte->getULong($this->offset) == 0 ? false : true;
     $this->offset += 2;
     if ($isFixedPitch) {
         $this->fdt['Flags'] |= 1;
     }
 }
예제 #2
0
 /**
  * Get the font type
  *
  * @param string $font_type      Font type. Leave empty for autodetect mode.
  *
  * @return string
  */
 protected function getFontType($font_type)
 {
     // autodetect font type
     if (empty($font_type)) {
         if (substr($this->font, 0, 16) == 'StartFontMetrics') {
             // AFM type - we use this type only for the 14 Core fonts
             return 'Core';
         }
         if (substr($this->font, 0, 4) == 'OTTO') {
             throw new FontException('Unsupported font format: OpenType with CFF data');
         }
         if ($this->fbyte->getULong(0) == 0x10000) {
             return 'TrueTypeUnicode';
         }
         return 'Type1';
     }
     if (strpos($font_type, 'CID0') === 0) {
         return 'cidfont0';
     }
     if (in_array($font_type, array('Core', 'Type1', 'TrueType', 'TrueTypeUnicode'))) {
         return $font_type;
     }
     throw new FontException('unknown or unsupported font type: ' . $font_type);
 }
예제 #3
0
 /**
  * Extract chunks data from a PNG image
  *
  * @param string $data   Image raw data
  * @param int    $offset Current byte offset
  *
  * @return array Image raw data array
  */
 protected function getChunks($data, $offset)
 {
     $byte = new Byte($data['raw']);
     while (($len = $byte->getULong($offset)) >= 0) {
         $offset += 4;
         $type = substr($data['raw'], $offset, 4);
         $offset += 4;
         if ($type == 'PLTE') {
             $data = $this->getPlteChunk($data, $offset, $len);
         } elseif ($type == 'tRNS') {
             $data = $this->getTrnsChunk($data, $offset, $len);
         } elseif ($type == 'IDAT') {
             $data = $this->getIdatChunk($data, $offset, $len);
         } elseif ($type == 'iCCP') {
             $data = $this->getIccpChunk($byte, $data, $offset, $len);
         } elseif ($type == 'IEND') {
             // The image trailer chunk (IEND) must be the final chunk
             // and marks the end of the PNG file or data stream.
             break;
         } else {
             $offset += $len;
             $offset += 4;
         }
     }
     if ($data['colspace'] == 'Indexed' && empty($data['pal'])) {
         // @codeCoverageIgnoreStart
         throw new ImageException('The color palette is missing');
         // @codeCoverageIgnoreEnd
     }
     return $data;
 }