Пример #1
0
 /**
 * Overloaded GetStringWidth for calculating a String width with another Font/size than the current one
 */
 function GetStringWidth($s, $psFontFamily = '', $psSize = '')
 {
     if ($psFontFamily == '' or $psSize == '' or !array_key_exists($psFontFamily, $this->fonts)) {
         return parent::GetStringWidth($s);
     }
     //Get width of a string in the current font
     $s = (string) $s;
     $cw = $this->fonts[$psFontFamily]['cw'];
     $w = 0;
     $l = strlen($s);
     for ($i = 0; $i < $l; $i++) {
         $w += $cw[$s[$i]];
     }
     return $w * $psSize / 1000;
 }