Пример #1
0
 /**
  * Store font data
  */
 protected function storeFontData()
 {
     // read first segment
     $dat = unpack('Cmarker/Ctype/Vsize', substr($this->font, 0, 6));
     if ($dat['marker'] != 128) {
         throw new FontException('Font file is not a valid binary Type1');
     }
     $this->fdt['size1'] = $dat['size'];
     $data = substr($this->font, 6, $this->fdt['size1']);
     // read second segment
     $dat = unpack('Cmarker/Ctype/Vsize', substr($this->font, 6 + $this->fdt['size1'], 6));
     if ($dat['marker'] != 128) {
         throw new FontException('Font file is not a valid binary Type1');
     }
     $this->fdt['size2'] = $dat['size'];
     $this->fdt['encrypted'] = substr($this->font, 12 + $this->fdt['size1'], $this->fdt['size2']);
     $data .= $this->fdt['encrypted'];
     // store compressed font
     $this->fdt['file'] = $this->fdt['file_name'] . '.z';
     $file = new File();
     $fpt = $file->fopenLocal($this->fdt['dir'] . $this->fdt['file'], 'wb');
     fwrite($fpt, gzcompress($data));
     fclose($fpt);
 }
Пример #2
0
 /**
  * Get the original image raw data
  *
  * @param string $image Image file name, URL or a '@' character followed by the image data string.
  *                      To link an image without embedding it on the document, set an asterisk character
  *                      before the URL (i.e.: '*http://www.example.com/image.jpg').
  *
  * @return array Image data array
  */
 protected function getRawData($image)
 {
     // default data to return
     $data = array('key' => '', 'defprint' => false, 'raw' => '', 'file' => '', 'exturl' => false, 'width' => 0, 'height' => 0, 'type' => 0, 'native' => false, 'mapto' => IMAGETYPE_PNG, 'bits' => 8, 'channels' => 3, 'colspace' => 'DeviceRGB', 'icc' => '', 'filter' => 'FlateDecode', 'parms' => '', 'pal' => '', 'trns' => array(), 'data' => '', 'ismask' => false);
     if (empty($image)) {
         throw new ImageException('Empty image');
     }
     if ($image[0] === '@') {
         // image from string
         $data['raw'] = substr($image, 1);
     } else {
         if ($image[0] === '*') {
             // not-embedded external URL
             $data['exturl'] = true;
             $image = substr($image, 1);
         }
         $data['file'] = $image;
         $fobj = new File();
         $data['raw'] = $fobj->getFileData($image);
     }
     return $this->getMetaData($data);
 }
Пример #3
0
 /**
  * Copy or link the original font file
  */
 protected function setFontFile()
 {
     if (!empty($this->fdt['desc'])) {
         // subsetting mode
         $this->fdt['Flags'] = $this->fdt['desc']['Flags'];
         return;
     }
     if ($this->fdt['type'] != 'cidfont0') {
         if ($this->fdt['linked']) {
             // creates a symbolic link to the existing font
             symlink($this->fdt['input_file'], $this->fdt['dir'] . $this->fdt['file_name']);
         } else {
             // store compressed font
             $this->fdt['file'] = $this->fdt['file_name'] . '.z';
             $file = new File();
             $fpt = $file->fopenLocal($this->fdt['dir'] . $this->fdt['file'], 'wb');
             fwrite($fpt, gzcompress($this->font));
             fclose($fpt);
         }
     }
 }
Пример #4
0
 /**
  * Save the eported metadata font file
  */
 protected function saveFontData()
 {
     $pfile = '{' . '"type":"' . $this->fdt['type'] . '"' . ',"name":"' . $this->fdt['name'] . '"' . ',"up":' . $this->fdt['underlinePosition'] . ',"ut":' . $this->fdt['underlineThickness'] . ',"dw":' . ($this->fdt['MissingWidth'] > 0 ? $this->fdt['MissingWidth'] : $this->fdt['AvgWidth']) . ',"diff":"' . $this->fdt['diff'] . '"' . ',"platform_id":' . $this->fdt['platform_id'] . ',"encoding_id":' . $this->fdt['encoding_id'];
     if ($this->fdt['type'] == 'Core') {
         // Core
         $pfile .= ',"enc":""';
     } elseif ($this->fdt['type'] == 'Type1') {
         // Type 1
         $pfile .= ',"enc":"' . $this->fdt['enc'] . '"' . ',"file":"' . $this->fdt['file'] . '"' . ',"size1":' . $this->fdt['size1'] . ',"size2":' . $this->fdt['size2'];
     } else {
         $pfile .= ',"originalsize":' . $this->fdt['originalsize'];
         if ($this->fdt['type'] == 'cidfont0') {
             $pfile .= ',' . UniToCid::$type[$this->fdt['settype']];
         } else {
             // TrueType
             $pfile .= ',"enc":"' . $this->fdt['enc'] . '"' . ',"file":"' . $this->fdt['file'] . '"' . ',"ctg":"' . $this->fdt['ctg'] . '"';
             // create CIDToGIDMap
             $cidtogidmap = str_pad('', 131072, "");
             // (256 * 256 * 2) = 131072
             foreach ($this->fdt['ctgdata'] as $cid => $gid) {
                 $cidtogidmap = $this->updateCIDtoGIDmap($cidtogidmap, $cid, $gid);
             }
             // store compressed CIDToGIDMap
             $file = new File();
             $fpt = $file->fopenLocal($this->fdt['dir'] . $this->fdt['ctg'], 'wb');
             fwrite($fpt, gzcompress($cidtogidmap));
             fclose($fpt);
         }
     }
     if ($this->fdt['isUnicode']) {
         $pfile .= ',"isUnicode":true';
     } else {
         $pfile .= ',"isUnicode":false';
     }
     $pfile .= ',"desc":{' . '"Flags":' . $this->fdt['Flags'] . ',"FontBBox":"[' . $this->fdt['bbox'] . ']"' . ',"ItalicAngle":' . $this->fdt['italicAngle'] . ',"Ascent":' . $this->fdt['Ascent'] . ',"Descent":' . $this->fdt['Descent'] . ',"Leading":' . $this->fdt['Leading'] . ',"CapHeight":' . $this->fdt['CapHeight'] . ',"XHeight":' . $this->fdt['XHeight'] . ',"StemV":' . $this->fdt['StemV'] . ',"StemH":' . $this->fdt['StemH'] . ',"AvgWidth":' . $this->fdt['AvgWidth'] . ',"MaxWidth":' . $this->fdt['MaxWidth'] . ',"MissingWidth":' . $this->fdt['MissingWidth'] . '}';
     if (!empty($this->fdt['cbbox'])) {
         $pfile .= ',"cbbox":{' . substr($this->fdt['cbbox'], 1) . '}';
     }
     $pfile .= ',"cw":{' . substr($this->fdt['cw'], 1) . '}';
     $pfile .= '}' . "\n";
     // store file
     $file = new File();
     $fpt = $file->fopenLocal($this->fdt['datafile'], 'wb');
     fwrite($fpt, $pfile);
     fclose($fpt);
 }