當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Zend_Pdf_Resource_Font::glyphNumbersForCharacters方法代碼示例

本文整理匯總了PHP中Zend_Pdf_Resource_Font::glyphNumbersForCharacters方法的典型用法代碼示例。如果您正苦於以下問題:PHP Zend_Pdf_Resource_Font::glyphNumbersForCharacters方法的具體用法?PHP Zend_Pdf_Resource_Font::glyphNumbersForCharacters怎麽用?PHP Zend_Pdf_Resource_Font::glyphNumbersForCharacters使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Zend_Pdf_Resource_Font的用法示例。


在下文中一共展示了Zend_Pdf_Resource_Font::glyphNumbersForCharacters方法的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::glyphNumbersForCharacters方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。