MDL-19270 - Quiz graph - Fix reverse display of Hebrew legend text in RTL mode

This commit is contained in:
Nadav Kavalerchik
2014-07-09 14:57:31 +03:00
parent 7a4832ecb9
commit 94e2dc1daf
2 changed files with 29 additions and 1 deletions
+17 -1
View File
@@ -1190,10 +1190,26 @@ class graph {
//ImageColorTransparent($this->image, $this->colour['white']); // colour for transparency
}
/**
* Prepare label's text for GD output.
*
* @param string $label string to be prepared.
* @return string Reversed input string, if we are in RTL mode and has no numbers.
* Otherwise, returns the string as is.
*/
private function prepare_label_text($label) {
if (right_to_left() and !preg_match('/[0-9]/i', $label)) {
return core_text::strrev($label);
} else {
return $label;
}
}
function print_TTF($message) {
$points = $message['points'];
$angle = $message['angle'];
$text = $message['text'];
// We have to manually reverse the label, since php GD cannot handle RTL characters properly in UTF8 strings.
$text = $this->prepare_label_text($message['text']);
$colour = $this->colour[$message['colour']];
$font = $this->parameter['path_to_fonts'].$message['font'];