Index: lib/graphlib.php =================================================================== RCS file: /cvsroot/moodle/moodle/lib/graphlib.php,v retrieving revision 1.20.10.6 diff -u -r1.20.10.6 graphlib.php --- lib/graphlib.php 18 Jan 2010 15:24:19 -0000 1.20.10.6 +++ lib/graphlib.php 5 Aug 2010 14:02:23 -0000 @@ -1243,8 +1243,25 @@ } // start of Moodle addition $textlib = textlib_get_instance(); - $text = $textlib->utf8_to_entities($text, true, true); //does not work with hex entities! - // end of Moodle addition + $textiniso8 = $textlib->convert($text, 'UTF-8', 'ISO-8859-8'); + if ($text == $textlib->convert($textiniso8, 'ISO-8859-8', 'UTF-8')) { + // If the text can be losslessly converted to the hebrew character set + // and back, then use hebrev to 'fix' the character order, because + // ImageTTFText cannot cope with RTL languages. + $text = $textlib->convert(hebrev($textiniso8), 'ISO-8859-8', 'UTF-8'); + } else { + $textiniso6 = $textlib->convert($text, 'UTF-8', 'ISO-8859-6'); + if ($text == $textlib->convert($textiniso6, 'ISO-8859-6', 'UTF-8')) { + // ... and the same, but for arabic. + $text = $textlib->convert(hebrev($textiniso6), 'ISO-8859-6', 'UTF-8'); + } + } + + // start of Moodle addition + // ImageTTFText does not work with hex entities! + $text = $textlib->utf8_to_entities($text, true, true); + + // end of Moodle additions ImageTTFText($this->image, $points, $angle, $x, $y, $colour, $font, $text); }