/** * Object constructor * * @todo Joing this class with Zend_Pdf_Resource_Font_Simple_Parsed_TrueType * * @param Zend_Pdf_FileParser_Font_OpenType_TrueType $fontParser Font parser * object containing parsed TrueType file. * @param integer $embeddingOptions Options for font embedding. * @throws Zend_Pdf_Exception */ public function __construct(Zend_Pdf_FileParser_Font_OpenType_TrueType $fontParser, $embeddingOptions) { parent::__construct($fontParser, $embeddingOptions); $this->_fontType = Zend_Pdf_Font::TYPE_CIDFONT_TYPE_2; $this->_resource->Subtype = new Zend_Pdf_Element_Name('CIDFontType2'); $fontDescriptor = Zend_Pdf_Resource_Font_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("\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", 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 Zend_Pdf_Element_Name('FlateDecode'); $this->_resource->CIDToGIDMap = $cidToGidMap; }
/** * Returns the width of the glyph. * * Like {@link widthsForGlyphs()} but used for one glyph at a time. * * @param integer $glyphNumber * @return integer * @throws Zend_Pdf_Exception */ public function widthForGlyph($glyphNumber) { return $this->_descendantFont->widthForChar($glyphNumber); }
public function __construct(Zend_Pdf_FileParser_Font_OpenType_TrueType $fontParser, $embeddingOptions) { parent::__construct($fontParser, $embeddingOptions); $this->_fontType = Zend_Pdf_Font::TYPE_CIDFONT_TYPE_2; $this->_resource->Subtype = new Zend_Pdf_Element_Name('CIDFontType2'); $fontDescriptor = Zend_Pdf_Resource_Font_FontDescriptor::factory($this, $fontParser, $embeddingOptions); $this->_resource->FontDescriptor = $this->_objectFactory->newObject($fontDescriptor); $cidToGidMapData = str_repeat("", 8192); $charGlyphs = $this->_cmap->getCoveredCharactersGlyphs(); foreach ($charGlyphs as $charCode => $glyph) { $cidToGidMapData[$charCode * 2] = chr($glyph >> 8); $cidToGidMapData[$charCode * 2 + 1] = chr($glyph & 0xff); } $cidToGidMap = $this->_objectFactory->newStreamObject($cidToGidMapData); $cidToGidMap->dictionary->Filter = new Zend_Pdf_Element_Name('FlateDecode'); $this->_resource->CIDToGIDMap = $cidToGidMap; }