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


PHP Zend_Pdf_Resource_Font::toEmSpace方法代码示例

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


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

示例1: 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

示例2: factory

 public static function factory(Zend_Pdf_Resource_Font $font, Zend_Pdf_FileParser_Font_OpenType $fontParser, $embeddingOptions)
 {
     $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);
     $flags = 0;
     if ($fontParser->isMonospaced) {
         $flags |= 1 << 0;
     }
     if ($fontParser->isSerifFont) {
         $flags |= 1 << 1;
     }
     if (!$fontParser->isAdobeLatinSubset) {
         $flags |= 1 << 2;
     }
     if ($fontParser->isScriptFont) {
         $flags |= 1 << 3;
     }
     if ($fontParser->isAdobeLatinSubset) {
         $flags |= 1 << 5;
     }
     if ($fontParser->isItalic) {
         $flags |= 1 << 6;
     }
     $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);
     $fontDescriptor->StemV = new Zend_Pdf_Element_Numeric(0);
     $fontDescriptor->MissingWidth = new Zend_Pdf_Element_Numeric($fontParser->glyphWidths[0]);
     if (!($embeddingOptions & Zend_Pdf_Font::EMBED_DONT_EMBED)) {
         if (!$fontParser->isEmbeddable) {
             if (!($embeddingOptions & Zend_Pdf_Font::EMBED_SUPPRESS_EMBED_EXCEPTION)) {
                 $message = 'This font cannot be embedded in the PDF document. If you would like to use ' . 'it anyway, you must pass Zend_Pdf_Font::EMBED_SUPPRESS_EMBED_EXCEPTION ' . 'in the $options parameter of the font constructor.';
                 throw new Zend_Pdf_Exception($message, Zend_Pdf_Exception::FONT_CANT_BE_EMBEDDED);
             }
         } else {
             $fontFile = $fontParser->getDataSource()->readAllBytes();
             $fontFileObject = $font->getFactory()->newStreamObject($fontFile);
             $fontFileObject->dictionary->Length1 = new Zend_Pdf_Element_Numeric(strlen($fontFile));
             if (!($embeddingOptions & Zend_Pdf_Font::EMBED_DONT_COMPRESS)) {
                 $fontFileObject->dictionary->Filter = new Zend_Pdf_Element_Name('FlateDecode');
             }
             if ($fontParser instanceof Zend_Pdf_FileParser_Font_OpenType_Type1) {
                 $fontDescriptor->FontFile = $fontFileObject;
             } else {
                 if ($fontParser instanceof Zend_Pdf_FileParser_Font_OpenType_TrueType) {
                     $fontDescriptor->FontFile2 = $fontFileObject;
                 } else {
                     $fontDescriptor->FontFile3 = $fontFileObject;
                 }
             }
         }
     }
     return $fontDescriptor;
 }
开发者ID:subashemphasize,项目名称:test_site,代码行数:59,代码来源:Pdf_Pack.php


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