当前位置: 首页>>代码示例>>PHP>>正文


PHP Zend_Pdf_Cmap::getCoveredCharactersGlyphs方法代码示例

本文整理汇总了PHP中Zend_Pdf_Cmap::getCoveredCharactersGlyphs方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Pdf_Cmap::getCoveredCharactersGlyphs方法的具体用法?PHP Zend_Pdf_Cmap::getCoveredCharactersGlyphs怎么用?PHP Zend_Pdf_Cmap::getCoveredCharactersGlyphs使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Zend_Pdf_Cmap的用法示例。


在下文中一共展示了Zend_Pdf_Cmap::getCoveredCharactersGlyphs方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: __construct

 /**
  * Object constructor
  *
  * @param Zend_Pdf_FileParser_Font_OpenType $fontParser Font parser object
  *   containing OpenType file.
  * @param integer $embeddingOptions Options for font embedding.
  * @throws Zend_Pdf_Exception
  */
 public function __construct(Zend_Pdf_FileParser_Font_OpenType $fontParser)
 {
     parent::__construct();
     $fontParser->parse();
     /* Object properties */
     $this->_fontNames = $fontParser->names;
     $this->_isBold = $fontParser->isBold;
     $this->_isItalic = $fontParser->isItalic;
     $this->_isMonospaced = $fontParser->isMonospaced;
     $this->_underlinePosition = $fontParser->underlinePosition;
     $this->_underlineThickness = $fontParser->underlineThickness;
     $this->_strikePosition = $fontParser->strikePosition;
     $this->_strikeThickness = $fontParser->strikeThickness;
     $this->_unitsPerEm = $fontParser->unitsPerEm;
     $this->_ascent = $fontParser->ascent;
     $this->_descent = $fontParser->descent;
     $this->_lineGap = $fontParser->lineGap;
     $this->_cmap = $fontParser->cmap;
     /* Resource dictionary */
     $baseFont = $this->getFontName(Zend_Pdf_Font::NAME_POSTSCRIPT, 'en', 'UTF-8');
     $this->_resource->BaseFont = new Zend_Pdf_Element_Name($baseFont);
     /**
      * Prepare widths array.
      */
     /* Constract characters widths array using font CMap and glyphs widths array */
     $glyphWidths = $fontParser->glyphWidths;
     $charGlyphs = $this->_cmap->getCoveredCharactersGlyphs();
     $charWidths = array();
     foreach ($charGlyphs as $charCode => $glyph) {
         if (isset($glyphWidths[$glyph]) && !is_null($glyphWidths[$glyph])) {
             $charWidths[$charCode] = $glyphWidths[$glyph];
         }
     }
     $this->_charWidths = $charWidths;
     $this->_missingCharWidth = $glyphWidths[0];
     /* Width array optimization. Step1: extract default value */
     $widthFrequencies = array_count_values($charWidths);
     $defaultWidth = null;
     $defaultWidthFrequency = -1;
     foreach ($widthFrequencies as $width => $frequency) {
         if ($frequency > $defaultWidthFrequency) {
             $defaultWidth = $width;
             $defaultWidthFrequency = $frequency;
         }
     }
     // Store default value in the font dictionary
     $this->_resource->DW = new Zend_Pdf_Element_Numeric($this->toEmSpace($defaultWidth));
     // Remove characters which corresponds to default width from the widths array
     $defWidthChars = array_keys($charWidths, $defaultWidth);
     foreach ($defWidthChars as $charCode) {
         unset($charWidths[$charCode]);
     }
     // Order cheracter widths aray by character codes
     ksort($charWidths, SORT_NUMERIC);
     /* Width array optimization. Step2: Compact character codes sequences */
     $lastCharCode = -1;
     $widthsSequences = array();
     foreach ($charWidths as $charCode => $width) {
         if ($lastCharCode == -1) {
             $charCodesSequense = array();
             $sequenceStartCode = $charCode;
         } else {
             if ($charCode != $lastCharCode + 1) {
                 // New chracters sequence detected
                 $widthsSequences[$sequenceStartCode] = $charCodesSequense;
                 $charCodesSequense = array();
                 $sequenceStartCode = $charCode;
             }
         }
         $charCodesSequense[] = $width;
         $lastCharCode = $charCode;
     }
     // Save last sequence, if widths array is not empty (it may happens for monospaced fonts)
     if (count($charWidths) != 0) {
         $widthsSequences[$sequenceStartCode] = $charCodesSequense;
     }
     $pdfCharsWidths = array();
     foreach ($widthsSequences as $startCode => $widthsSequence) {
         /* Width array optimization. Step3: Compact widths sequences */
         $pdfWidths = array();
         $lastWidth = -1;
         $widthsInSequence = 0;
         foreach ($widthsSequence as $width) {
             if ($lastWidth != $width) {
                 // New width is detected
                 if ($widthsInSequence != 0) {
                     // Previous width value was a part of the widths sequence. Save it as 'c_1st c_last w'.
                     $pdfCharsWidths[] = new Zend_Pdf_Element_Numeric($startCode);
                     // First character code
                     $pdfCharsWidths[] = new Zend_Pdf_Element_Numeric($startCode + $widthsInSequence - 1);
                     // Last character code
                     $pdfCharsWidths[] = new Zend_Pdf_Element_Numeric($this->toEmSpace($lastWidth));
//.........这里部分代码省略.........
开发者ID:tenstone,项目名称:wecenter,代码行数:101,代码来源:CidFont.php


注:本文中的Zend_Pdf_Cmap::getCoveredCharactersGlyphs方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。