• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP Zend_Pdf_FileParser_Font_OpenType类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: __construct

    /**
     * Object constructor
     *
     * @param Zend_Pdf_FileParser_Font_OpenType $fontParser Font parser object containing OpenType file.
     * @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->_glyphWidths       = $fontParser->glyphWidths;
        $this->_missingGlyphWidth = $this->_glyphWidths[0];


        $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);

        $this->_resource->FirstChar = new Zend_Pdf_Element_Numeric(0);
        $this->_resource->LastChar  = new Zend_Pdf_Element_Numeric(count($this->_glyphWidths) - 1);

        /* Now convert the scalar glyph widths to Zend_Pdf_Element_Numeric objects.
         */
        $pdfWidths = array();
        foreach ($this->_glyphWidths as $width) {
            $pdfWidths[] = new Zend_Pdf_Element_Numeric($this->toEmSpace($width));
        }
        /* Create the Zend_Pdf_Element_Array object and add it to the font's
         * object factory and resource dictionary.
         */
        $widthsArrayElement = new Zend_Pdf_Element_Array($pdfWidths);
        $widthsObject = $this->_objectFactory->newObject($widthsArrayElement);
        $this->_resource->Widths = $widthsObject;
    }
开发者ID:nhp,项目名称:shopware-4,代码行数:60,代码来源:Parsed.php


示例2: __construct

 /**
  * Object constructor
  *
  * The $embeddingOptions parameter allows you to set certain flags related
  * to font embedding. You may combine options by OR-ing them together. See
  * the EMBED_ constants defined in {@link Zend_Pdf_Font} for the list of
  * available options and their descriptions.
  *
  * Note that it is not requried that fonts be embedded within the PDF file
  * to use them. If the recipient of the PDF has the font installed on their
  * computer, they will see the correct fonts in the document. If they don't,
  * the PDF viewer will substitute or synthesize a replacement.
  *
  * @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, $embeddingOptions)
 {
     $fontParser->parse();
     parent::__construct($embeddingOptions);
     /* 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->_glyphWidths = $fontParser->glyphWidths;
     $this->_glyphMaxIndex = count($this->_glyphWidths) - 1;
     $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);
     $this->_resource->FirstChar = new Zend_Pdf_Element_Numeric(0);
     $this->_resource->LastChar = new Zend_Pdf_Element_Numeric(255);
     /* Build up the widths array and add it as an indirect object. The
      * character codes contained in this array are the Unicode characters
      * representing the WinAnsi (CP1252) character set. This corresponds to
      * to encoding method specified below.
      */
     $characterCodes = array(0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f, 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f, 0x20ac, 0x0, 0x201a, 0x192, 0x201e, 0x2026, 0x2020, 0x2021, 0x2c6, 0x2030, 0x160, 0x2039, 0x152, 0x0, 0x17d, 0x0, 0x0, 0x2018, 0x2019, 0x201c, 0x201d, 0x2022, 0x2013, 0x2014, 0x2dc, 0x2122, 0x161, 0x203a, 0x153, 0x0, 0x17e, 0x178, 0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf, 0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, 0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf, 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, 0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf, 0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef, 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff);
     /* Convert characters to glyphs and then get the widths.
      */
     $glyphNumbers = $this->cmap->glyphNumbersForCharacters($characterCodes);
     $glyphWidths = $this->widthsForGlyphs($glyphNumbers);
     /* Now convert the scalar glyph widths to Zend_Pdf_Element_Numeric objects.
      */
     $pdfWidths = array();
     foreach ($glyphWidths as $width) {
         $pdfWidths[] = new Zend_Pdf_Element_Numeric($this->_toEmSpace($width));
     }
     /* Create the Zend_Pdf_Element_Array object and add it to the font's
      * object factory and resource dictionary.
      */
     $widthsArrayElement = new Zend_Pdf_Element_Array($pdfWidths);
     $widthsObject = $this->_objectFactory->newObject($widthsArrayElement);
     $this->_resource->Widths = $widthsObject;
     $this->_resource->Encoding = new Zend_Pdf_Element_Name('WinAnsiEncoding');
 }
开发者ID:BackupTheBerlios,项目名称:openpublisher-svn,代码行数:67,代码来源:OpenType.php


示例3: factory

 /**
  * Object constructor
  * 
  * The $embeddingOptions parameter allows you to set certain flags related
  * to font embedding. You may combine options by OR-ing them together. See
  * the EMBED_ constants defined in {@link Zend_Pdf_Font} for the list of
  * available options and their descriptions.
  *
  * Note that it is not requried that fonts be embedded within the PDF file
  * to use them. If the recipient of the PDF has the font installed on their
  * computer, they will see the correct fonts in the document. If they don't,
  * the PDF viewer will substitute or synthesize a replacement.
  * 
  * 
  * @param Zend_Pdf_Resource_Font $font Font
  * @param Zend_Pdf_FileParser_Font_OpenType $fontParser Font parser object containing parsed TrueType file.
  * @param integer $embeddingOptions Options for font embedding.
  * @return Zend_Pdf_Element_Dictionary
  * @throws Zend_Pdf_Exception
  */
 public static function factory(Zend_Pdf_Resource_Font $font, Zend_Pdf_FileParser_Font_OpenType $fontParser, $embeddingOptions)
 {
     /* The font descriptor object contains the rest of the font metrics and
      * the information about the embedded font program (if applicible).
      */
     $fontDescriptor = new Zend_Pdf_Element_Dictionary();
     $fontDescriptor->Type = new Zend_Pdf_Element_Name('FontDescriptor');
     $fontDescriptor->FontName = new Zend_Pdf_Element_Name($font->getResource()->BaseFont->value);
     /* The font flags value is a bitfield that describes the stylistic
      * attributes of the font. We will set as many of the bits as can be
      * determined from the font parser.
      */
     $flags = 0;
     if ($fontParser->isMonospaced) {
         // bit 1: FixedPitch
         $flags |= 1 << 0;
     }
     if ($fontParser->isSerifFont) {
         // bit 2: Serif
         $flags |= 1 << 1;
     }
     if (!$fontParser->isAdobeLatinSubset) {
         // bit 3: Symbolic
         $flags |= 1 << 2;
     }
     if ($fontParser->isScriptFont) {
         // bit 4: Script
         $flags |= 1 << 3;
     }
     if ($fontParser->isAdobeLatinSubset) {
         // bit 6: Nonsymbolic
         $flags |= 1 << 5;
     }
     if ($fontParser->isItalic) {
         // bit 7: Italic
         $flags |= 1 << 6;
     }
     // bits 17-19: AllCap, SmallCap, ForceBold; not available
     $fontDescriptor->Flags = new Zend_Pdf_Element_Numeric($flags);
     $fontBBox = array(new Zend_Pdf_Element_Numeric($font->toEmSpace($fontParser->xMin)), new Zend_Pdf_Element_Numeric($font->toEmSpace($fontParser->yMin)), new Zend_Pdf_Element_Numeric($font->toEmSpace($fontParser->xMax)), new Zend_Pdf_Element_Numeric($font->toEmSpace($fontParser->yMax)));
     $fontDescriptor->FontBBox = new Zend_Pdf_Element_Array($fontBBox);
     $fontDescriptor->ItalicAngle = new Zend_Pdf_Element_Numeric($fontParser->italicAngle);
     $fontDescriptor->Ascent = new Zend_Pdf_Element_Numeric($font->toEmSpace($fontParser->ascent));
     $fontDescriptor->Descent = new Zend_Pdf_Element_Numeric($font->toEmSpace($fontParser->descent));
     $fontDescriptor->CapHeight = new Zend_Pdf_Element_Numeric($fontParser->capitalHeight);
     /**
      * The vertical stem width is not yet extracted from the OpenType font
      * file. For now, record zero which is interpreted as 'unknown'.
      * @todo Calculate value for StemV.
      */
     $fontDescriptor->StemV = new Zend_Pdf_Element_Numeric(0);
     $fontDescriptor->MissingWidth = new Zend_Pdf_Element_Numeric($fontParser->glyphWidths[0]);
     /* Set up font embedding. This is where the actual font program itself
      * is embedded within the PDF document.
      *
      * Note that it is not requried that fonts be embedded within the PDF
      * document to use them. If the recipient of the PDF has the font
      * installed on their computer, they will see the correct fonts in the
      * document. If they don't, the PDF viewer will substitute or synthesize
      * a replacement.
      *
      * There are several guidelines for font embedding:
      *
      * First, the developer might specifically request not to embed the font.
      */
     if (!($embeddingOptions & Zend_Pdf_Font::EMBED_DONT_EMBED)) {
         /* Second, the font author may have set copyright bits that prohibit
          * the font program from being embedded. Yes this is controversial,
          * but it's the rules:
          *   http://partners.adobe.com/public/developer/en/acrobat/sdk/FontPolicies.pdf
          *
          * To keep the developer in the loop, and to prevent surprising bug
          * reports of "your PDF doesn't have the right fonts," throw an
          * exception if the font cannot be embedded.
          */
         if (!$fontParser->isEmbeddable) {
             /* This exception may be suppressed if the developer decides that
              * it's not a big deal that the font program can't be embedded.
              */
             if (!($embeddingOptions & Zend_Pdf_Font::EMBED_SUPPRESS_EMBED_EXCEPTION)) {
//.........这里部分代码省略.........
开发者ID:lortnus,项目名称:zf1,代码行数:101,代码来源:FontDescriptor.php


示例4: __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


示例5: parse

 /**
  * Reads and parses the TrueType font data from the file on disk.
  *
  * @throws Zend_Pdf_Exception
  */
 public function parse()
 {
     if ($this->_isParsed) {
         return;
     }
     parent::parse();
     /* There is nothing additional to parse for TrueType fonts at this time.
      */
     $this->_isParsed = true;
 }
开发者ID:dalinhuang,项目名称:popo,代码行数:15,代码来源:TrueType.php


示例6: parse

 public function parse()
 {
     if ($this->_isParsed) {
         return;
     }
     parent::parse();
     $this->_isParsed = true;
 }
开发者ID:subashemphasize,项目名称:test_site,代码行数:8,代码来源:Pdf_Pack.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP Zend_Pdf_Font类代码示例发布时间:2022-05-23
下一篇:
PHP Zend_Pdf_Element_String类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap