tFPDF::GetStringWidth PHP Метод

GetStringWidth() публичный Метод

public GetStringWidth ( $s )
    function GetStringWidth($s)
    {
        // Get width of a string in the current font
        $s = (string) $s;
        $cw =& $this->CurrentFont['cw'];
        $w = 0;
        if ($this->unifontSubset) {
            $unicode = $this->UTF8StringToArray($s);
            foreach ($unicode as $char) {
                if (isset($cw[$char])) {
                    $w += (ord($cw[2 * $char]) << 8) + ord($cw[2 * $char + 1]);
                } else {
                    if ($char > 0 && $char < 128 && isset($cw[chr($char)])) {
                        $w += $cw[chr($char)];
                    } else {
                        if (isset($this->CurrentFont['desc']['MissingWidth'])) {
                            $w += $this->CurrentFont['desc']['MissingWidth'];
                        } else {
                            if (isset($this->CurrentFont['MissingWidth'])) {
                                $w += $this->CurrentFont['MissingWidth'];
                            } else {
                                $w += 500;
                            }
                        }
                    }
                }
            }
        } else {
            $l = strlen($s);
            for ($i = 0; $i < $l; $i++) {
                $w += $cw[$s[$i]];
            }
        }
        return $w * $this->FontSize / 1000;
    }