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


PHP Zend_Pdf_Resource_Font::widthsForGlyphs方法代码示例

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


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

示例1: widthForStringUsingFontSize

 /**
  * Returns the total width in points of the string using the specified font and
  * size.
  *
  * This is not the most efficient way to perform this calculation. I'm
  * concentrating optimization efforts on the upcoming layout manager class.
  * Similar calculations exist inside the layout manager class, but widths are
  * generally calculated only after determining line fragments.
  *
  * @param string $string
  * @param Zend_Pdf_Resource_Font $font
  * @param float $fontSize Font size in points
  * @return float
  */
 public function widthForStringUsingFontSize($string, $font, $fontSize)
 {
     $drawingString = '"libiconv"' == ICONV_IMPL ? iconv('UTF-8', 'UTF-16BE//IGNORE', $string) : @iconv('UTF-8', 'UTF-16BE', $string);
     $characters = array();
     for ($i = 0; $i < strlen($drawingString); $i++) {
         $characters[] = ord($drawingString[$i++]) << 8 | ord($drawingString[$i]);
     }
     $glyphs = $font->glyphNumbersForCharacters($characters);
     $widths = $font->widthsForGlyphs($glyphs);
     $stringWidth = array_sum($widths) / $font->getUnitsPerEm() * $fontSize;
     return $stringWidth;
 }
开发者ID:codercv,项目名称:urbansurprisedev,代码行数:26,代码来源:Abstract.php

示例2: getTextWidth

 /**
  * Calculate the width of given text in points taking into account current font and font-size
  *
  * @param string $text
  * @param Zend_Pdf_Resource_Font $font
  * @param float $font_size
  * @return float
  */
 public function getTextWidth($text, Zend_Pdf_Resource_Font $font, $font_size)
 {
     $drawing_text = iconv('', 'UTF-16BE', $text);
     $characters = array();
     for ($i = 0; $i < strlen($drawing_text); $i++) {
         $characters[] = ord($drawing_text[$i++]) << 8 | ord($drawing_text[$i]);
     }
     $glyphs = $font->glyphNumbersForCharacters($characters);
     $widths = $font->widthsForGlyphs($glyphs);
     $text_width = array_sum($widths) / $font->getUnitsPerEm() * $font_size;
     return $text_width;
 }
开发者ID:usamatahir,项目名称:BulletProof,代码行数:20,代码来源:Page.php

示例3: width_to_points

 /**
  * Returns the total width in points of the string using the specified font and
  * size.
  *
  * This is not the most efficient way to perform this calculation. I'm
  * concentrating optimization efforts on the upcoming layout manager class.
  * Similar calculations exist inside the layout manager class, but widths are
  * generally calculated only after determining line fragments.
  * 
  * @link http://devzone.zend.com/article/2525-Zend_Pdf-tutorial#comments-2535 
  * @param string $string
  * @param Zend_Pdf_Resource_Font $font
  * @param float $fontSize Font size in points
  * @return float
  */
 protected function width_to_points($string, $font, $fontSize)
 {
     try {
         $drawingString = iconv('UTF-8', 'UTF-16BE//IGNORE', $string);
         $characters = array();
         for ($i = 0; $i < strlen($drawingString); $i++) {
             $characters[] = ord($drawingString[$i++]) << 8 | ord($drawingString[$i]);
         }
         $glyphs = $font->glyphNumbersForCharacters($characters);
         $widths = $font->widthsForGlyphs($glyphs);
         $stringWidth = array_sum($widths) / $font->getUnitsPerEm() * $fontSize;
     } catch (Exception $e) {
         die($e->getMessage);
     }
     return $stringWidth;
 }
开发者ID:kokkez,项目名称:shineisp,代码行数:31,代码来源:Pdf.php


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