Example #1
0
 /**
  * Object constructor
  *
  * @param \ZendPdf\BinaryParser\Font\OpenType\TrueType $fontParser Font parser
  *   object containing parsed TrueType file.
  * @param integer $embeddingOptions Options for font embedding.
  * @throws \ZendPdf\Exception\ExceptionInterface
  */
 public function __construct(OpenTypeFontParser\TrueType $fontParser, $embeddingOptions)
 {
     parent::__construct($fontParser, $embeddingOptions);
     $this->_fontType = Pdf\Font::TYPE_TRUETYPE;
     $this->_resource->Subtype = new InternalType\NameObject('TrueType');
     $fontDescriptor = FontResource\FontDescriptor::factory($this, $fontParser, $embeddingOptions);
     $this->_resource->FontDescriptor = $this->_objectFactory->newObject($fontDescriptor);
 }
Example #2
0
 /**
  * Object constructor
  *
  * @todo Joing this class with \ZendPdf\Resource\Font\Simple\Parsed\TrueType
  *
  * @param \ZendPdf\BinaryParser\Font\OpenType\TrueType $fontParser Font parser
  *   object containing parsed TrueType file.
  * @param integer $embeddingOptions Options for font embedding.
  * @throws \ZendPdf\Exception\ExceptionInterface
  */
 public function __construct(OpenTypeFontParser\TrueType $fontParser, $embeddingOptions)
 {
     parent::__construct($fontParser, $embeddingOptions);
     $this->_fontType = Pdf\Font::TYPE_CIDFONT_TYPE_2;
     $this->_resource->Subtype = new InternalType\NameObject('CIDFontType2');
     $fontDescriptor = FontResource\FontDescriptor::factory($this, $fontParser, $embeddingOptions);
     $this->_resource->FontDescriptor = $this->_objectFactory->newObject($fontDescriptor);
     /* Prepare CIDToGIDMap */
     // Initialize 128K string of null characters (65536 2 byte integers)
     $cidToGidMapData = str_repeat("", 8192);
     // Fill the index
     $charGlyphs = $this->_cmap->getCoveredCharactersGlyphs();
     foreach ($charGlyphs as $charCode => $glyph) {
         $cidToGidMapData[$charCode * 2] = chr($glyph >> 8);
         $cidToGidMapData[$charCode * 2 + 1] = chr($glyph & 0xff);
     }
     // Store CIDToGIDMap within compressed stream object
     $cidToGidMap = $this->_objectFactory->newStreamObject($cidToGidMapData);
     $cidToGidMap->dictionary->Filter = new InternalType\NameObject('FlateDecode');
     $this->_resource->CIDToGIDMap = $cidToGidMap;
 }