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


PHP TCPDF_FONTS::UTF8ArrToLatin1Arr方法代码示例

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


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

示例1: GetArrStringWidth

 /**
  * Returns the string length of an array of chars in user unit or an array of characters widths. A font must be selected.<br>
  * @param $sa (string) The array of chars whose total length is to be computed
  * @param $fontname (string) Family font. It can be either a name defined by AddFont() or one of the standard families. It is also possible to pass an empty string, in that case, the current family is retained.
  * @param $fontstyle (string) Font style. Possible values are (case insensitive):<ul><li>empty string: regular</li><li>B: bold</li><li>I: italic</li><li>U: underline</li><li>D: line through</li><li>O: overline</li></ul> or any combination. The default value is regular.
  * @param $fontsize (float) Font size in points. The default value is the current size.
  * @param $getarray (boolean) if true returns an array of characters widths, if false returns the total length.
  * @return mixed int total string length or array of characted widths
  * @author Nicola Asuni
  * @public
  * @since 2.4.000 (2008-03-06)
  */
 public function GetArrStringWidth($sa, $fontname = '', $fontstyle = '', $fontsize = 0, $getarray = false)
 {
     // store current values
     if (!TCPDF_STATIC::empty_string($fontname)) {
         $prev_FontFamily = $this->FontFamily;
         $prev_FontStyle = $this->FontStyle;
         $prev_FontSizePt = $this->FontSizePt;
         $this->SetFont($fontname, $fontstyle, $fontsize, '', 'default', false);
     }
     // convert UTF-8 array to Latin1 if required
     if ($this->isunicode and !$this->isUnicodeFont()) {
         $sa = TCPDF_FONTS::UTF8ArrToLatin1Arr($sa);
     }
     $w = 0;
     // total width
     $wa = array();
     // array of characters widths
     foreach ($sa as $ck => $char) {
         // character width
         $cw = $this->GetCharWidth($char, isset($sa[$ck + 1]));
         $wa[] = $cw;
         $w += $cw;
     }
     // restore previous values
     if (!TCPDF_STATIC::empty_string($fontname)) {
         $this->SetFont($prev_FontFamily, $prev_FontStyle, $prev_FontSizePt, '', 'default', false);
     }
     if ($getarray) {
         return $wa;
     }
     return $w;
 }
开发者ID:TheTypoMaster,项目名称:myapps,代码行数:44,代码来源:tcpdf.php


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