Exemple #1
0
 /**
  * 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;
 }
Exemple #2
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("\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 InternalType\NameObject('FlateDecode');
        $this->_resource->CIDToGIDMap = $cidToGidMap;
    }
Exemple #3
0
 /**
  * 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\ExceptionInterface
  */
 public function widthForGlyph($glyphNumber)
 {
     return $this->_descendantFont->widthForChar($glyphNumber);
 }