Exemple #1
0
 public function Convert($aTxt, $aFF)
 {
     if (LANGUAGE_GREEK) {
         if (GREEK_FROM_WINDOWS) {
             $unistring = LanguageConv::gr_win2uni($aTxt);
         } else {
             $unistring = LanguageConv::gr_iso2uni($aTxt);
         }
         return $unistring;
     } elseif (LANGUAGE_CYRILLIC) {
         if (CYRILLIC_FROM_WINDOWS && (!defined('LANGUAGE_CHARSET') || stristr(LANGUAGE_CHARSET, 'windows-1251'))) {
             $aTxt = convert_cyr_string($aTxt, "w", "k");
         }
         if (!defined('LANGUAGE_CHARSET') || stristr(LANGUAGE_CHARSET, 'koi8-r') || stristr(LANGUAGE_CHARSET, 'windows-1251')) {
             $isostring = convert_cyr_string($aTxt, "k", "i");
             $unistring = LanguageConv::iso2uni($isostring);
         } else {
             $unistring = $aTxt;
         }
         return $unistring;
     } elseif ($aFF === FF_SIMSUN) {
         // Do Chinese conversion
         if ($this->g2312 == null) {
             include_once 'jpgraph_gb2312.php';
             $this->g2312 = new GB2312toUTF8();
         }
         return $this->g2312->gb2utf8($aTxt);
     } elseif ($aFF === FF_BIG5) {
         if (!function_exists('iconv')) {
             JpGraphError::RaiseL(25006);
             //('Usage of FF_CHINESE (FF_BIG5) font family requires that your PHP setup has the iconv() function. By default this is not compiled into PHP (needs the "--width-iconv" when configured).');
         }
         return iconv('BIG5', 'UTF-8', $aTxt);
     } elseif (ASSUME_EUCJP_ENCODING && ($aFF == FF_MINCHO || $aFF == FF_GOTHIC || $aFF == FF_PMINCHO || $aFF == FF_PGOTHIC)) {
         if (!function_exists('mb_convert_encoding')) {
             JpGraphError::RaiseL(25127);
         }
         return mb_convert_encoding($aTxt, 'UTF-8', 'EUC-JP');
     } elseif ($aFF == FF_DAVID || $aFF == FF_MIRIAM || $aFF == FF_AHRON) {
         return LanguageConv::heb_iso2uni($aTxt);
     } else {
         return $aTxt;
     }
 }
 function Convert($aTxt, $aFF)
 {
     if (LANGUAGE_GREEK) {
         if (GREEK_FROM_WINDOWS) {
             $unistring = LanguageConv::gr_win2uni($aTxt);
         } else {
             $unistring = LanguageConv::gr_iso2uni($aTxt);
         }
         return $unistring;
     } elseif (LANGUAGE_CYRILLIC) {
         if (CYRILLIC_FROM_WINDOWS && (!defined('CYRILLIC_LANGUAGE_CHARSET') || stristr(CYRILLIC_LANGUAGE_CHARSET, 'windows-1251'))) {
             $aTxt = convert_cyr_string($aTxt, "w", "k");
         }
         if (!defined('CYRILLIC_LANGUAGE_CHARSET') || stristr(CYRILLIC_LANGUAGE_CHARSET, 'koi8-r') || stristr(CYRILLIC_LANGUAGE_CHARSET, 'windows-1251')) {
             $isostring = convert_cyr_string($aTxt, "k", "i");
             $unistring = LanguageConv::iso2uni($isostring);
         } else {
             $unistring = $aTxt;
         }
         return $unistring;
     } elseif ($aFF === FF_SIMSUN) {
         if ($this->g2312 == null) {
             include_once 'jpgraph_gb2312.php';
             $this->g2312 = new GB2312toUTF8();
         }
         return $this->g2312->gb2utf8($aTxt);
     } elseif ($aFF === FF_CHINESE) {
         if (!function_exists('iconv')) {
             JpGraphError::RaiseL(25006);
         }
         return iconv('BIG5', 'UTF-8', $aTxt);
     } elseif (ASSUME_EUCJP_ENCODING && ($aFF == FF_MINCHO || $aFF == FF_GOTHIC || $aFF == FF_PMINCHO || $aFF == FF_PGOTHIC)) {
         if (!function_exists('mb_convert_encoding')) {
             JpGraphError::RaiseL(25127);
         }
         return mb_convert_encoding($aTxt, 'UTF-8', 'EUC-JP');
     } elseif ($aFF == FF_DAVID || $aFF == FF_MIRIAM || $aFF == FF_AHRON) {
         return $this->heb_iso2uni($aTxt);
     } else {
         return $aTxt;
     }
 }
Exemple #3
0
 function Convert($aTxt, $aFF)
 {
     if (LANGUAGE_CYRILLIC) {
         if (CYRILLIC_FROM_WINDOWS) {
             $aTxt = convert_cyr_string($aTxt, "w", "k");
         }
         $isostring = convert_cyr_string($aTxt, "k", "i");
         $unistring = LanguageConv::iso2uni($isostring);
         return $unistring;
     } elseif ($aFF === FF_SIMSUN) {
         // Do Chinese conversion
         if ($this->g2312 == null) {
             include_once 'jpgraph_gb2312.php';
             $this->g2312 = new GB2312toUTF8();
         }
         return $this->g2312->gb2utf8($aTxt);
     } elseif ($aFF === FF_CHINESE) {
         if (!function_exists('iconv')) {
             JpGraphError::Raise('Usage of FF_CHINESE (FF_BIG5) font family requires that your PHP setup has the iconv() function. By default this is not compiled into PHP (needs the "--width-iconv" when configured).');
         }
         return iconv('BIG5', 'UTF-8', $aTxt);
     } else {
         return $aTxt;
     }
 }
Exemple #4
0
 function Convert($aTxt, $aFF)
 {
     if (LANGUAGE_CYRILLIC) {
         /* Auto-detect whether the cyrillic conversion
          ** based on the character_set info that has 
          ** been passed to jpgraph from the including
          ** application.
          **
          ** Call the cyrillic converter only when a cyrillic 
          ** charset derivate is used. Otherwise do nothing 
          ** and prevent from erraneously converted strings.
          */
         if (CYRILLIC_FROM_WINDOWS && (!defined('LANGUAGE_CHARSET') || stristr(LANGUAGE_CHARSET, 'windows-1251'))) {
             $aTxt = convert_cyr_string($aTxt, "w", "k");
         }
         if (!defined('LANGUAGE_CHARSET') || stristr(LANGUAGE_CHARSET, 'koi8-r') || stristr(LANGUAGE_CHARSET, 'windows-1251')) {
             $isostring = convert_cyr_string($aTxt, "k", "i");
             $unistring = LanguageConv::iso2uni($isostring);
         } else {
             $unistring = $aTxt;
         }
         return $unistring;
     } elseif ($aFF === FF_SIMSUN) {
         // Do Chinese conversion
         if ($this->g2312 == null) {
             include_once 'jpgraph_gb2312.php';
             $this->g2312 = new GB2312toUTF8();
         }
         return $this->g2312->gb2utf8($aTxt);
     } elseif ($aFF === FF_CHINESE) {
         if (!function_exists('iconv')) {
             JpGraphError::RaiseL(25006);
             //('Usage of FF_CHINESE (FF_BIG5) font family requires that your PHP setup has the iconv() function. By default this is not compiled into PHP (needs the "--width-iconv" when configured).');
         }
         return iconv('BIG5', 'UTF-8', $aTxt);
     } else {
         return $aTxt;
     }
 }
Exemple #5
0
 function StrokeText($x, $y, $txt, $dir = 0, $paragraph_align = "left")
 {
     // Do special language encoding
     if (LANGUAGE_CYRILLIC) {
         $txt = LanguageConv::ToCyrillic($txt);
     }
     if (!is_numeric($dir)) {
         JpGraphError::Raise(" Direction for text most be given as an angle between 0 and 90.");
     }
     if ($this->font_family >= FF_FONT0 && $this->font_family <= FF_FONT2 + 1) {
         // Internal font
         if (is_numeric($dir) && $dir != 90 && $dir != 0) {
             JpGraphError::Raise(" Internal font does not support drawing text at arbitrary angle. Use TTF fonts instead.");
         }
         $h = $this->GetTextHeight($txt);
         $fh = $this->GetFontHeight($txt);
         $w = $this->GetTextWidth($txt);
         if ($this->text_halign == "right") {
             $x -= $dir == 0 ? $w : $h;
         } elseif ($this->text_halign == "center") {
             $x -= $dir == 0 ? $w / 2 : $h / 2;
         }
         if ($this->text_valign == "top") {
             $y += $dir == 0 ? $h : $w;
         } elseif ($this->text_valign == "center") {
             $y += $dir == 0 ? $h / 2 : $w / 2;
         }
         if ($dir == 90) {
             imagestringup($this->img, $this->font_family, $x, $y, $txt, $this->current_color);
         } else {
             if (ereg("\n", $txt)) {
                 $tmp = explode("\n", $txt);
                 for ($i = 0; $i < count($tmp); ++$i) {
                     $w1 = $this->GetTextWidth($tmp[$i]);
                     if ($paragraph_align == "left") {
                         imagestring($this->img, $this->font_family, $x, $y - $h + 1 + $i * $fh, $tmp[$i], $this->current_color);
                     } elseif ($paragraph_align == "right") {
                         imagestring($this->img, $this->font_family, $x + ($w - $w1), $y - $h + 1 + $i * $fh, $tmp[$i], $this->current_color);
                     } else {
                         imagestring($this->img, $this->font_family, $x + $w / 2 - $w1 / 2, $y - $h + 1 + $i * $fh, $tmp[$i], $this->current_color);
                     }
                 }
             } else {
                 //Put the text
                 imagestring($this->img, $this->font_family, $x, $y - $h + 1, $txt, $this->current_color);
             }
         }
     } elseif ($this->font_family >= FF_COURIER && $this->font_family <= FF_BOOK) {
         // TTF font
         $file = $this->ttf->File($this->font_family, $this->font_style);
         $angle = $dir;
         $bbox = ImageTTFBBox($this->font_size, $angle, $file, $txt);
         if ($this->text_halign == "right") {
             $x -= $bbox[2] - $bbox[0];
         } elseif ($this->text_halign == "center") {
             $x -= ($bbox[4] - $bbox[0]) / 2;
         } elseif ($this->text_halign == "topanchor") {
             $x -= $bbox[4] - $bbox[0];
         } elseif ($this->text_halign == "left") {
             $x += -($bbox[6] - $bbox[0]);
         }
         if ($this->text_valign == "top") {
             $y -= $bbox[5];
         } elseif ($this->text_valign == "center") {
             $y -= ($bbox[5] - $bbox[1]) / 2;
         } elseif ($this->text_valign == "bottom") {
             $y -= $bbox[1];
         }
         // Use lower left of bbox as fix-point, not the default baselinepoint.
         $x -= $bbox[0];
         if ($GLOBALS['gd2']) {
             $old = ImageAlphaBlending($this->img, true);
         }
         ImageTTFText($this->img, $this->font_size, $angle, $x, $y, $this->current_color, $file, $txt);
         if ($GLOBALS['gd2']) {
             ImageAlphaBlending($this->img, $old);
         }
     } else {
         JpGraphError::Raise(" Unknown font font family specification. ");
     }
 }
Exemple #6
0
 function Convert($aTxt, $aFF)
 {
     if (LANGUAGE_CYRILLIC) {
         if (CYRILLIC_FROM_WINDOWS) {
             $aTxt = convert_cyr_string($aTxt, "w", "k");
         }
         $isostring = convert_cyr_string($aTxt, "k", "i");
         $unistring = LanguageConv::iso2uni($isostring);
         return $unistring;
     } elseif ($aFF === FF_SIMSUN) {
         // Do Chinese conversion
         if ($this->g2312 == null) {
             include_once 'jpgraph_gb2312.php';
             $this->g2312 = new GB2312toUTF8();
         }
         return $this->g2312->gb2utf8($aTxt);
     } else {
         return $aTxt;
     }
 }
Exemple #7
0
 function StrokeText($x, $y, $txt, $dir = 0, $paragraph_align = "left", $debug = false)
 {
     $x = round($x);
     $y = round($y);
     // Do special language encoding
     if (LANGUAGE_CYRILLIC) {
         $txt = LanguageConv::ToCyrillic($txt);
     }
     if (!is_numeric($dir)) {
         JpGraphError::Raise(" Direction for text most be given as an angle between 0 and 90.");
     }
     if ($this->font_family >= FF_FONT0 && $this->font_family <= FF_FONT2 + 1) {
         $this->_StrokeBuiltinFont($x, $y, $txt, $dir, $paragraph_align, $debug);
     } elseif ($this->font_family >= FF_COURIER && $this->font_family <= FF_BOOK) {
         $this->_StrokeTTF($x, $y, $txt, $dir, $paragraph_align, $debug);
     } else {
         JpGraphError::Raise(" Unknown font font family specification. ");
     }
 }
Exemple #8
0
 function ToCyrillic($aTxt)
 {
     if (false) {
         $aTxt = convert_cyr_string($aTxt, "w", "k");
     }
     $isostring = convert_cyr_string($aTxt, "k", "i");
     $unistring = LanguageConv::iso2uni($isostring);
     return $unistring;
 }
Exemple #9
0
 function Convert($aTxt, $aFF)
 {
     if (LANGUAGE_CYRILLIC) {
         if (CYRILLIC_FROM_WINDOWS) {
             $aTxt = convert_cyr_string($aTxt, "w", "k");
         }
         $isostring = convert_cyr_string($aTxt, "k", "i");
         $unistring = LanguageConv::iso2uni($isostring);
         return $unistring;
     } elseif (LANGUAGE_GREEK) {
         $isoline = $aTxt;
         for ($i = 0; $i < strlen($isoline); $i++) {
             $thischar = substr($isoline, $i, 1);
             $charcode = ord($thischar);
             $uniline .= $charcode > 175 ? "&#" . (896 + ($charcode - 176)) . ";" : $thischar;
         }
         return $uniline;
     } elseif ($aFF === FF_SIMSUN) {
         // Do Chinese conversion
         if ($this->g2312 == null) {
             include_once 'jpgraph_gb2312.php';
             $this->g2312 = new GB2312toUTF8();
         }
         return $this->g2312->gb2utf8($aTxt);
     } elseif ($aFF === FF_CHINESE) {
         if (!function_exists('iconv')) {
             JpGraphError::Raise('Usage of FF_CHINESE (FF_BIG5) font family requires that your PHP setup has the iconv() function. By default this is not compiled into PHP (needs the "--width-iconv" when configured).');
         }
         return iconv('BIG-5', 'UTF8', $aTxt);
     } else {
         return $aTxt;
     }
 }