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


PHP TCPDF_STATIC::getHyphenPatternsFromTEX方法代码示例

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


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

示例1: hyphenateText

 /**
  * Returns text with soft hyphens.
  * @param $text (string) text to process
  * @param $patterns (mixed) Array of hypenation patterns or a TEX file containing hypenation patterns. TEX patterns can be downloaded from http://www.ctan.org/tex-archive/language/hyph-utf8/tex/generic/hyph-utf8/patterns/
  * @param $dictionary (array) Array of words to be returned without applying the hyphenation algorithm.
  * @param $leftmin (int) Minimum number of character to leave on the left of the word without applying the hyphens.
  * @param $rightmin (int) Minimum number of character to leave on the right of the word without applying the hyphens.
  * @param $charmin (int) Minimum word length to apply the hyphenation algorithm.
  * @param $charmax (int) Maximum length of broken piece of word.
  * @return array text with soft hyphens
  * @author Nicola Asuni
  * @since 4.9.012 (2010-04-12)
  * @public
  */
 public function hyphenateText($text, $patterns, $dictionary = array(), $leftmin = 1, $rightmin = 2, $charmin = 1, $charmax = 8)
 {
     $text = $this->unhtmlentities($text);
     $word = array();
     // last word
     $txtarr = array();
     // text to be returned
     $intag = false;
     // true if we are inside an HTML tag
     $skip = false;
     // true to skip hyphenation
     if (!is_array($patterns)) {
         $patterns = TCPDF_STATIC::getHyphenPatternsFromTEX($patterns);
     }
     // get array of characters
     $unichars = TCPDF_FONTS::UTF8StringToArray($text, $this->isunicode, $this->CurrentFont);
     // for each char
     foreach ($unichars as $char) {
         if (!$intag and !$skip and TCPDF_FONT_DATA::$uni_type[$char] == 'L') {
             // letter character
             $word[] = $char;
         } else {
             // other type of character
             if (!TCPDF_STATIC::empty_string($word)) {
                 // hypenate the word
                 $txtarr = array_merge($txtarr, $this->hyphenateWord($word, $patterns, $dictionary, $leftmin, $rightmin, $charmin, $charmax));
                 $word = array();
             }
             $txtarr[] = $char;
             if (chr($char) == '<') {
                 // we are inside an HTML tag
                 $intag = true;
             } elseif ($intag and chr($char) == '>') {
                 // end of HTML tag
                 $intag = false;
                 // check for style tag
                 $expected = array(115, 116, 121, 108, 101);
                 // = 'style'
                 $current = array_slice($txtarr, -6, 5);
                 // last 5 chars
                 $compare = array_diff($expected, $current);
                 if (empty($compare)) {
                     // check if it is a closing tag
                     $expected = array(47);
                     // = '/'
                     $current = array_slice($txtarr, -7, 1);
                     $compare = array_diff($expected, $current);
                     if (empty($compare)) {
                         // closing style tag
                         $skip = false;
                     } else {
                         // opening style tag
                         $skip = true;
                     }
                 }
             }
         }
     }
     if (!TCPDF_STATIC::empty_string($word)) {
         // hypenate the word
         $txtarr = array_merge($txtarr, $this->hyphenateWord($word, $patterns, $dictionary, $leftmin, $rightmin, $charmin, $charmax));
     }
     // convert char array to string and return
     return TCPDF_FONTS::UTF8ArrSubString($txtarr, '', '', $this->isunicode);
 }
开发者ID:developmentDM2,项目名称:The-Haute-Mess,代码行数:79,代码来源:tcpdf.php

示例2: hyphenateText

 /**
  * Returns text with soft hyphens.
  * @param $text (string) text to process
  * @param $patterns (mixed) Array of hypenation patterns or a TEX file containing hypenation patterns. TEX patterns can be downloaded from http://www.ctan.org/tex-archive/language/hyph-utf8/tex/generic/hyph-utf8/patterns/
  * @param $dictionary (array) Array of words to be returned without applying the hyphenation algoritm.
  * @param $leftmin (int) Minimum number of character to leave on the left of the word without applying the hyphens.
  * @param $rightmin (int) Minimum number of character to leave on the right of the word without applying the hyphens.
  * @param $charmin (int) Minimum word length to apply the hyphenation algoritm.
  * @param $charmax (int) Maximum length of broken piece of word.
  * @return array text with soft hyphens
  * @author Nicola Asuni
  * @since 4.9.012 (2010-04-12)
  * @public
  */
 public function hyphenateText($text, $patterns, $dictionary = array(), $leftmin = 1, $rightmin = 2, $charmin = 1, $charmax = 8)
 {
     $text = $this->unhtmlentities($text);
     $word = array();
     // last word
     $txtarr = array();
     // text to be returned
     $intag = false;
     // true if we are inside an HTML tag
     if (!is_array($patterns)) {
         $patterns = TCPDF_STATIC::getHyphenPatternsFromTEX($patterns);
     }
     // get array of characters
     $unichars = TCPDF_FONTS::UTF8StringToArray($text, $this->isunicode, $this->CurrentFont);
     // for each char
     foreach ($unichars as $char) {
         if (!$intag and TCPDF_FONT_DATA::$uni_type[$char] == 'L') {
             // letter character
             $word[] = $char;
         } else {
             // other type of character
             if (!TCPDF_STATIC::empty_string($word)) {
                 // hypenate the word
                 $txtarr = array_merge($txtarr, $this->hyphenateWord($word, $patterns, $dictionary, $leftmin, $rightmin, $charmin, $charmax));
                 $word = array();
             }
             $txtarr[] = $char;
             if (chr($char) == '<') {
                 // we are inside an HTML tag
                 $intag = true;
             } elseif ($intag and chr($char) == '>') {
                 // end of HTML tag
                 $intag = false;
             }
         }
     }
     if (!TCPDF_STATIC::empty_string($word)) {
         // hypenate the word
         $txtarr = array_merge($txtarr, $this->hyphenateWord($word, $patterns, $dictionary, $leftmin, $rightmin, $charmin, $charmax));
     }
     // convert char array to string and return
     return TCPDF_FONTS::UTF8ArrSubString($txtarr, '', '', $this->isunicode);
 }
开发者ID:TheTypoMaster,项目名称:myapps,代码行数:57,代码来源:tcpdf.php

示例3: renderRow

 protected function renderRow($x, $y, $row, $options, &$view = NULL, $key = NULL, $printLabels = TRUE)
 {
     $pageDim = $this->getPageDimensions();
     // Render the content if it is not already:
     if (is_object($view) && $key != NULL && isset($view->field[$key]) && is_object($view->field[$key]) && !is_string($row)) {
         $content = $view->field[$key]->theme($row);
     } elseif (is_string($row)) {
         $content = $row;
     } else {
         // We got bad data. So return.
         return;
     }
     if (empty($key) || !empty($view->field[$key]->options['exclude']) || empty($content) && $view->field[$key]->options['hide_empty']) {
         return '';
     }
     // Apply the hyphenation patterns to the content:
     if (!isset($options['text']['hyphenate']) && is_object($view) && is_object($view->display_handler)) {
         $options['text']['hyphenate'] = $view->display_handler->get_option('default_text_hyphenate');
     }
     if (isset($options['text']['hyphenate']) && $options['text']['hyphenate'] != 'none') {
         $patternFile = $options['text']['hyphenate'];
         if ($options['text']['hyphenate'] == 'auto' && is_object($row)) {
             // Workaround:
             // Since "$nodeLanguage = $row->node_language;" does not work anymore,
             // we using this:
             if (isset($row->_field_data['nid']['entity']->language)) {
                 $nodeLanguage = $row->_field_data['nid']['entity']->language;
                 foreach (self::getAvailableHyphenatePatterns() as $file => $pattern) {
                     if (stristr($pattern, $nodeLanguage) !== FALSE) {
                         $patternFile = $file;
                         break;
                     }
                 }
             }
         }
         $patternFile = views_pdf_get_library('tcpdf') . '/hyphenate_patterns/' . $patternFile;
         if (file_exists($patternFile)) {
             if (method_exists('TCPDF_STATIC', 'getHyphenPatternsFromTEX')) {
                 $hyphen_patterns = TCPDF_STATIC::getHyphenPatternsFromTEX($patternFile);
             } else {
                 $hyphen_patterns = $this->getHyphenPatternsFromTEX($patternFile);
             }
             // Bugfix if you like to print some html code to the PDF, we
             // need to prevent the replacement of this tags.
             $content = str_replace('&gt;', '&amp;gt;', $content);
             $content = str_replace('&lt;', '&amp;lt;', $content);
             $content = $this->hyphenateText($content, $hyphen_patterns);
         }
     }
     // Set css variable
     if (is_object($view) && is_object($view->display_handler)) {
         $css_file = $view->display_handler->get_option('css_file');
     }
     // Render Labels
     $prefix = '';
     if ($printLabels && !empty($view->field[$key]->options['label'])) {
         $prefix = $view->field[$key]->options['label'];
         if ($view->field[$key]->options['element_label_colon']) {
             $prefix .= ':';
         }
         $prefix .= ' ';
     }
     $font_size = empty($options['text']['font_size']) ? $this->defaultFontSize : $options['text']['font_size'];
     $font_family = $options['text']['font_family'] == 'default' || empty($options['text']['font_family']) ? $this->defaultFontFamily : $options['text']['font_family'];
     $font_style = is_array($options['text']['font_style']) ? $options['text']['font_style'] : $this->defaultFontStyle;
     $textColor = !empty($options['text']['color']) ? $this->parseColor($options['text']['color']) : $this->parseColor($this->defaultFontColor);
     $w = $options['position']['width'];
     $h = $options['position']['height'];
     $border = 0;
     $align = isset($options['text']['align']) ? $options['text']['align'] : $this->defaultTextAlign;
     $fill = 0;
     $ln = 1;
     $reseth = TRUE;
     $stretch = 0;
     $ishtml = isset($options['render']['is_html']) ? $options['render']['is_html'] : 1;
     $stripHTML = !$ishtml;
     $autopadding = TRUE;
     $maxh = 0;
     $valign = 'T';
     $fitcell = FALSE;
     // Run eval before.
     if (!empty($options['render']['bypass_eval_before']) && !empty($options['render']['eval_before'])) {
         eval($options['render']['eval_before']);
     } elseif (!empty($options['render']['eval_before'])) {
         $content = php_eval($options['render']['eval_before']);
     }
     // Add css if there is a css file set and stripHTML is not active.
     if (!empty($css_file) && is_string($css_file) && !$stripHTML && $ishtml && !empty($content)) {
         $content = '<link type="text/css" rel="stylesheet" media="all" href="' . $css_file . '" />' . PHP_EOL . $content;
     }
     // Set Text Color.
     $this->SetTextColorArray($textColor);
     // Set font.
     $this->SetFont($font_family, implode('', $font_style), $font_size);
     // Save the last page before starting writing, this
     // is needed to dected if we write over a page. Then we need
     // to reset the y coordinate for the 'last_writing' position option.
     $this->lastWritingPage = $this->getPage();
     if ($stripHTML) {
         $content = strip_tags($content);
//.........这里部分代码省略.........
开发者ID:kastowo,项目名称:idbigdata,代码行数:101,代码来源:views_pdf_template.php


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