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


PHP Zend_Pdf_Font::_extractTrueTypeFont方法代码示例

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


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

示例1: fontWithPath

 /**
  * Returns a {@link Zend_Pdf_Resource_Font} object by file path.
  *
  * The result of this method is cached, preventing unnecessary duplication
  * of font objects. Repetitive calls for the font with the same path will
  * return the same object.
  *
  * 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 this value is only
  * used when creating a font for the first time. If a font with the same
  * name already exists, you will get that object and the options you specify
  * here will be ignored. This is because fonts are only embedded within the
  * PDF file once.
  *
  * If the file path supplied does not match the path of a previously
  * instantiated object or the font type cannot be determined, an exception
  * will be thrown.
  *
  * @param string $filePath Full path to the font file.
  * @param integer $embeddingOptions (optional) Options for font embedding.
  * @return Zend_Pdf_Resource_Font
  * @throws Zend_Pdf_Exception
  */
 public static function fontWithPath($filePath, $embeddingOptions = 0)
 {
     /* First check the cache. Don't duplicate font objects.
      */
     $filePathKey = md5($filePath);
     if (isset(Zend_Pdf_Font::$_fontFilePaths[$filePathKey])) {
         return Zend_Pdf_Font::$_fontFilePaths[$filePathKey];
     }
     /* Create a file parser data source object for this file. File path and
      * access permission checks are handled here.
      */
     $dataSource = new Zend_Pdf_FileParserDataSource_File($filePath);
     /* Attempt to determine the type of font. We can't always trust file
      * extensions, but try that first since it's fastest.
      */
     $fileExtension = strtolower(pathinfo($filePath, PATHINFO_EXTENSION));
     /* If it turns out that the file is named improperly and we guess the
      * wrong type, we'll get null instead of a font object.
      */
     switch ($fileExtension) {
         case 'ttf':
             $font = Zend_Pdf_Font::_extractTrueTypeFont($dataSource, $embeddingOptions);
             break;
         default:
             /* Unrecognized extension. Try to determine the type by actually
              * parsing it below.
              */
             $font = null;
             break;
     }
     if ($font === null) {
         /* There was no match for the file extension or the extension was
          * wrong. Attempt to detect the type of font by actually parsing it.
          * We'll do the checks in order of most likely format to try to
          * reduce the detection time.
          */
         // OpenType
         // TrueType
         if ($font === null && $fileExtension != 'ttf') {
             $font = Zend_Pdf_Font::_extractTrueTypeFont($dataSource, $embeddingOptions);
         }
         // Type 1 PostScript
         // Mac OS X dfont
         // others?
     }
     /* Done with the data source object.
      */
     $dataSource = null;
     if ($font !== null) {
         /* Parsing was successful. Add this font instance to the cache arrays
          * and return it for use.
          */
         $fontName = $font->getFontName(Zend_Pdf_Font::NAME_POSTSCRIPT, '', '');
         Zend_Pdf_Font::$_fontNames[$fontName] = $font;
         $filePathKey = md5($filePath);
         Zend_Pdf_Font::$_fontFilePaths[$filePathKey] = $font;
         return $font;
     } else {
         /* The type of font could not be determined. Give up.
          */
         throw new Zend_Pdf_Exception("Cannot determine font type: {$filePath}", Zend_Pdf_Exception::CANT_DETERMINE_FONT_TYPE);
     }
 }
开发者ID:VUW-SIM-FIS,项目名称:emiemi,代码行数:88,代码来源:Font.php

示例2: fontWithPath

 public static function fontWithPath($filePath, $embeddingOptions = 0)
 {
     $filePathKey = md5($filePath);
     if (isset(Zend_Pdf_Font::$_fontFilePaths[$filePathKey])) {
         return Zend_Pdf_Font::$_fontFilePaths[$filePathKey];
     }
     $dataSource = new Zend_Pdf_FileParserDataSource_File($filePath);
     $fileExtension = strtolower(pathinfo($filePath, PATHINFO_EXTENSION));
     switch ($fileExtension) {
         case 'ttf':
             $font = Zend_Pdf_Font::_extractTrueTypeFont($dataSource, $embeddingOptions);
             break;
         default:
             $font = null;
             break;
     }
     if ($font === null) {
         if ($font === null && $fileExtension != 'ttf') {
             $font = Zend_Pdf_Font::_extractTrueTypeFont($dataSource, $embeddingOptions);
         }
     }
     $dataSource = null;
     if ($font !== null) {
         $fontName = $font->getFontName(Zend_Pdf_Font::NAME_POSTSCRIPT, '', '');
         Zend_Pdf_Font::$_fontNames[$fontName] = $font;
         $filePathKey = md5($filePath);
         Zend_Pdf_Font::$_fontFilePaths[$filePathKey] = $font;
         return $font;
     } else {
         throw new Zend_Pdf_Exception("Cannot determine font type: {$filePath}", Zend_Pdf_Exception::CANT_DETERMINE_FONT_TYPE);
     }
 }
开发者ID:subashemphasize,项目名称:test_site,代码行数:32,代码来源:Pdf_Pack.php


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