]> git.mjollnir.org Git - moodle.git/commitdiff
Uses iconv by default to convert texts into UTF-8 to keep GD happier.
authormoodler <moodler>
Wed, 28 Apr 2004 14:18:25 +0000 (14:18 +0000)
committermoodler <moodler>
Wed, 28 Apr 2004 14:18:25 +0000 (14:18 +0000)
lib/graphlib.php

index 4528577c46e6b01daf7e95a356f48949f4295d89..43029e421f4c3337924aad8213d86dd4d03c4886 100644 (file)
@@ -162,6 +162,17 @@ function init() {
   } else {
       $this->parameter['lang_decode'] = "";
   }
+
+  $this->parameter['lang_transcode'] = '';   /// by default
+
+  if (function_exists('iconv')) {
+      $charset = strtolower(get_string('thischarset'));
+
+      if ($charset != 'iso-8859-1' and $charset != 'utf-8') {
+          $this->parameter['lang_transcode'] = $charset;
+      }
+  }
+
   /// End Moodle mods
 
 
@@ -1224,6 +1235,9 @@ function print_TTF($message) {
   if ($this->parameter['lang_decode']) {               // Moodle addition
       include_once($this->parameter['lang_decode']);
       $text = lang_decode($text);
+
+  } else if ($this->parameter['lang_transcode']) {
+      $text = iconv($this->parameter['lang_transcode'], 'UTF-8', $text);
   }
   ImageTTFText($this->image, $points, $angle, $x, $y, $colour, $font, $text);
 }
@@ -1330,6 +1344,9 @@ function get_boundaryBox($message) {
     if ($this->parameter['lang_decode']) {               // Moodle addition
         include_once($this->parameter['lang_decode']);
         $text = lang_decode($text);
+
+    } else if ($this->parameter['lang_transcode']) {
+        $text = iconv($this->parameter['lang_transcode'], 'UTF-8', $text);
     }
        $bounds = ImageTTFBBox($points, $angle, $font, $text);