本文整理匯總了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;
}