STSongStd-Light-Acro') {
//Add GB font with half-width Latin
for ($i = 32; $i <= 126; $i++)
$cw[chr($i)] = 500;
$CMap = 'GBK-EUC-H';
$registry = array (
'ordering' => 'GB1',
'supplement' => 2
);
$this->AddCIDFonts($family, $name, $cw, $CMap, $registry);
}
function GetStringWidth($s) {
if ($this->CurrentFont['type'] == 'Type0')
return $this->GetMBStringWidth($s);
else
return parent :: GetStringWidth($s);
}
function GetMBStringWidth($s) {
//Multi-byte version of GetStringWidth()
$l = 0;
$cw = & $this->CurrentFont['cw'];
$nb = strlen($s);
$i = 0;
while ($i < $nb) {
$c = $s[$i];
if (ord($c) < 128) {
$l += $cw[$c];
$i++;
} else {
$l += 1000;
$i += 2;
}
}
return $l * $this->FontSize / 1000;
}
function MultiCell($w, $h, $txt, $border = 0, $align = 'L', $fill = 0) {
if ($this->CurrentFont['type'] == 'Type0')
$this->MBMultiCell($w, $h, $txt, $border, $align, $fill);
else
parent :: MultiCell($w, $h, $txt, $border, $align, $fill);
}
function MBMultiCell($w, $h, $txt, $border = 0, $align = 'L', $fill = 0) {
//Multi-byte version of MultiCell()
$cw = & $this->CurrentFont['cw'];
if ($w == 0)
$w = $this->w - $this->rMargin - $this->x;
$wmax = ($w -2 * $this->cMargin) * 1000 / $this->FontSize;
$s = str_replace("\r\n", "\n", $txt);
$nb = strlen($s);
if ($nb > 0 and $s[$nb -1] == "\n")
$nb--;
$b = 0;
if ($border) {
if ($border == 1) {
$border = 'LTRB';
$b = 'LRT';
$b2 = 'LR';
} else {
$b2 = '';
if (is_int(strpos($border, 'L')))
$b2 .= 'L';
if (is_int(strpos($border, 'R')))
$b2 .= 'R';
$b = is_int(strpos($border, 'T')) ? $b2 . 'T' : $b2;
}
}
$sep = -1;
$i = 0;
$j = 0;
$l = 0;
$nl = 1;
while ($i < $nb) {
//Get next character
$c = $s[$i];
//Check if ASCII or MB
$ascii = (ord($c) < 128);
if ($c == "\n") {
//Explicit line break
parent :: Cell($w, $h, substr($s, $j, $i - $j), $b, 2, $align, $fill);
$i++;
$sep = -1;
$j = $i;
$l = 0;
$nl++;
if ($border and $nl == 2)
$b = $b2;
continue;
}
if (!$ascii) {
$sep = $i;
$ls = $l;
}
elseif ($c == ' ') {
$sep = $i;
$ls = $l;
}
$l += $ascii ? $cw[$c] : 1000;
if ($l > $wmax) {
//Automatic line break
if ($sep == -1 or $i == $j) {
if ($i == $j)
$i += $ascii ? 1 : 2;
parent :: Cell($w, $h, substr($s, $j, $i - $j), $b, 2, $align, $fill);
} else {
parent :: Cell($w, $h, substr($s, $j, $sep - $j), $b, 2, $align, $fill);
$i = ($s[$sep] == ' ') ? $sep +1 : $sep;
}
$sep = -1;
$j = $i;
$l = 0;
$nl++;
if ($border and $nl == 2)
$b = $b2;
} else
$i += $ascii ? 1 : 2;
}
//Last chunk
if ($border and is_int(strpos($border, 'B')))
$b .= 'B';
parent :: Cell($w, $h, substr($s, $j, $i - $j), $b, 2, $align, $fill);
$this->x = $this->lMargin;
}
function Write($h, $txt, $link = '') {
if ($this->CurrentFont['type'] == 'Type0')
$this->MBWrite($h, $txt, $link);
else
parent :: Write($h, $txt, $link);
}
function MBWrite($h, $txt, $link = '') {
//Multi-byte version of Write()
$cw = & $this->CurrentFont['cw'];
$w = $this->w - $this->rMargin - $this->x;
$wmax = ($w -2 * $this->cMargin) * 1000 / $this->FontSize;
$s = str_replace("\r\n", "\n", $txt);
$nb = strlen($s);
$sep = -1;
$i = 0;
$j = 0;
$l = 0;
$nl = 1;
while ($i < $nb) {
//Get next character
$c = $s[$i];
//Check if ASCII or MB
$ascii = (ord($c) < 128);
if ($c == "\n") {
//Explicit line break
parent :: Cell($w, $h, substr($s, $j, $i - $j), 0, 2, '', 0, $link);
$i++;
$sep = -1;
$j = $i;
$l = 0;
if ($nl == 1) {
$this->x = $this->lMargin;
$w = $this->w - $this->rMargin - $this->x;
$wmax = ($w -2 * $this->cMargin) * 1000 / $this->FontSize;
}
$nl++;
continue;
}
if (!$ascii or $c == ' ')
$sep = $i;
$l += $ascii ? $cw[$c] : 1000;
if ($l > $wmax) {
//Automatic line break
if ($sep == -1 or $i == $j) {
if ($this->x > $this->lMargin) {
//Move to next line
$this->x = $this->lMargin;
$this->y += $h;
$w = $this->w - $this->rMargin - $this->x;
$wmax = ($w -2 * $this->cMargin) * 1000 / $this->FontSize;
$i++;
$nl++;
continue;
}