本文整理汇总了PHP中TCPDF_STATIC::pregSplit方法的典型用法代码示例。如果您正苦于以下问题:PHP TCPDF_STATIC::pregSplit方法的具体用法?PHP TCPDF_STATIC::pregSplit怎么用?PHP TCPDF_STATIC::pregSplit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TCPDF_STATIC
的用法示例。
在下文中一共展示了TCPDF_STATIC::pregSplit方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: writeHTML
//.........这里部分代码省略.........
}
$hrefstyle = -1;
if (isset($dom[$dom[$key]['parent']]['fontstyle']) and $dom[$dom[$key]['parent']]['fontstyle'] !== false) {
$hrefstyle = $dom[$dom[$key]['parent']]['fontstyle'];
}
$strrest = $this->addHtmlLink($this->HREF['url'], $dom[$key]['value'], $wfill, true, $hrefcolor, $hrefstyle, true);
} else {
$wadj = 0;
// space to leave for block continuity
if ($this->rtl) {
$cwa = $this->x - $this->lMargin;
} else {
$cwa = $this->w - $this->rMargin - $this->x;
}
if ($strlinelen < $cwa and isset($dom[$key + 1]) and $dom[$key + 1]['tag'] and !$dom[$key + 1]['block']) {
// check the next text blocks for continuity
$nkey = $key + 1;
$write_block = true;
$same_textdir = true;
$tmp_fontname = $this->FontFamily;
$tmp_fontstyle = $this->FontStyle;
$tmp_fontsize = $this->FontSizePt;
while ($write_block and isset($dom[$nkey])) {
if ($dom[$nkey]['tag']) {
if ($dom[$nkey]['block']) {
// end of block
$write_block = false;
}
$tmp_fontname = isset($dom[$nkey]['fontname']) ? $dom[$nkey]['fontname'] : $this->FontFamily;
$tmp_fontstyle = isset($dom[$nkey]['fontstyle']) ? $dom[$nkey]['fontstyle'] : $this->FontStyle;
$tmp_fontsize = isset($dom[$nkey]['fontsize']) ? $dom[$nkey]['fontsize'] : $this->FontSizePt;
$same_textdir = $dom[$nkey]['dir'] == $dom[$key]['dir'];
} else {
$nextstr = TCPDF_STATIC::pregSplit('/' . $this->re_space['p'] . '+/', $this->re_space['m'], $dom[$nkey]['value']);
if (isset($nextstr[0]) and $same_textdir) {
$wadj += $this->GetStringWidth($nextstr[0], $tmp_fontname, $tmp_fontstyle, $tmp_fontsize);
if (isset($nextstr[1])) {
$write_block = false;
}
}
}
++$nkey;
}
}
if ($wadj > 0 and $strlinelen + $wadj >= $cwa) {
$wadj = 0;
$nextstr = TCPDF_STATIC::pregSplit('/' . $this->re_space['p'] . '/', $this->re_space['m'], $dom[$key]['value']);
$numblks = count($nextstr);
if ($numblks > 1) {
// try to split on blank spaces
$wadj = $cwa - $strlinelen + $this->GetStringWidth($nextstr[$numblks - 1]);
} else {
// set the entire block on new line
$wadj = $this->GetStringWidth($nextstr[0]);
}
}
// check for reversed text direction
if ($wadj > 0 and ($this->rtl and $this->tmprtl === 'L' or !$this->rtl and $this->tmprtl === 'R')) {
// LTR text on RTL direction or RTL text on LTR direction
$reverse_dir = true;
$this->rtl = !$this->rtl;
$revshift = $strlinelen + $wadj + 1.0E-6;
// add little quantity for rounding problems
if ($this->rtl) {
$this->x += $revshift;
} else {
示例2: UTF8StringToArray
/**
* Converts UTF-8 strings to codepoints array.<br>
* Invalid byte sequences will be replaced with 0xFFFD (replacement character)<br>
* @param $str (string) string to process.
* @param $isunicode (boolean) True when the documetn is in Unicode mode, false otherwise.
* @param $currentfont (array) Reference to current font array.
* @return array containing codepoints (UTF-8 characters values)
* @author Nicola Asuni
* @public static
*/
public static function UTF8StringToArray($str, $isunicode=true, &$currentfont) {
if ($isunicode) {
// requires PCRE unicode support turned on
$chars = TCPDF_STATIC::pregSplit('//','u', $str, -1, PREG_SPLIT_NO_EMPTY);
$carr = array_map(array('TCPDF_FONTS', 'uniord'), $chars);
} else {
$chars = str_split($str);
$carr = array_map('ord', $chars);
}
$currentfont['subsetchars'] += array_fill_keys($carr, true);
return $carr;
}