Example #1
0
 /**
  * Object constructor
  *
  * @todo Joing this class with Zend_PDF_Resource_Font_Simple_Parsed_TrueType
  *
  * @param \Zend\PDF\BinaryParser\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(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;
 }
Example #2
0
File: Type0.php Project: stunti/zf2
 /**
  * Object constructor
  *
  */
 public function __construct(CIDFont\AbstractCIDFont $descendantFont)
 {
     parent::__construct();
     $this->_objectFactory->attach($descendantFont->getFactory());
     $this->_fontType = PDF\Font::TYPE_TYPE_0;
     $this->_descendantFont = $descendantFont;
     $this->_fontNames = $descendantFont->getFontNames();
     $this->_isBold = $descendantFont->isBold();
     $this->_isItalic = $descendantFont->isItalic();
     $this->_isMonospaced = $descendantFont->isMonospace();
     $this->_underlinePosition = $descendantFont->getUnderlinePosition();
     $this->_underlineThickness = $descendantFont->getUnderlineThickness();
     $this->_strikePosition = $descendantFont->getStrikePosition();
     $this->_strikeThickness = $descendantFont->getStrikeThickness();
     $this->_unitsPerEm = $descendantFont->getUnitsPerEm();
     $this->_ascent = $descendantFont->getAscent();
     $this->_descent = $descendantFont->getDescent();
     $this->_lineGap = $descendantFont->getLineGap();
     $this->_resource->Subtype = new InternalType\NameObject('Type0');
     $this->_resource->BaseFont = new InternalType\NameObject($descendantFont->getResource()->BaseFont->value);
     $this->_resource->DescendantFonts = new InternalType\ArrayObject(array($descendantFont->getResource()));
     $this->_resource->Encoding = new InternalType\NameObject('Identity-H');
     $toUnicode = $this->_objectFactory->newStreamObject(self::getToUnicodeCMapData());
     $this->_resource->ToUnicode = $toUnicode;
 }
Example #3
0
File: Type0.php Project: stunti/zf2
 /**
  * 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);
 }