public function test_utf8_to_entities() { $str = "Žluťoučký koníček"; $this->assertIdentical(textlib::utf8_to_entities($str), "Žluťoučký koníček"); $this->assertIdentical(textlib::utf8_to_entities($str, true), "Žluťoučký koníček"); }
/** * Tests the static utf8_to_entities method * @return void */ public function test_utf8_to_entities() { $str = "Žluťoučký koníček©"&<>§«"; $this->assertSame("Žluťoučký koníček©"&<>§«", textlib::utf8_to_entities($str)); $this->assertSame("Žluťoučký koníček©"&<>§«", textlib::utf8_to_entities($str, true)); $str = "Žluťoučký koníček©"&<>§«"; $this->assertSame("Žluťoučký koníček©\"&<>§«", textlib::utf8_to_entities($str, false, true)); $this->assertSame("Žluťoučký koníček©\"&<>§«", textlib::utf8_to_entities($str, true, true)); }
function get_boundaryBox($message) { $points = $message['points']; $angle = $message['angle']; $font = $this->parameter['path_to_fonts'] . $message['font']; $text = $message['text']; //print ('get_boundaryBox'); //expandPre($message); // get font size $bounds = ImageTTFBBox($points, $angle, $font, "W"); if ($angle < 0) { $fontHeight = abs($bounds[7] - $bounds[1]); } else { if ($angle > 0) { $fontHeight = abs($bounds[1] - $bounds[7]); } else { $fontHeight = abs($bounds[7] - $bounds[1]); } } // get boundary box and offsets for printing at an angle // start of Moodle addition $text = textlib::utf8_to_entities($text, true, true); //gd does not work with hex entities! // end of Moodle addition $bounds = ImageTTFBBox($points, $angle, $font, $text); if ($angle < 0) { $width = abs($bounds[4] - $bounds[0]); $height = abs($bounds[3] - $bounds[7]); $offsetY = abs($bounds[3] - $bounds[1]); $offsetX = 0; } else { if ($angle > 0) { $width = abs($bounds[2] - $bounds[6]); $height = abs($bounds[1] - $bounds[5]); $offsetY = 0; $offsetX = abs($bounds[0] - $bounds[6]); } else { $width = abs($bounds[4] - $bounds[6]); $height = abs($bounds[7] - $bounds[1]); $offsetY = $bounds[1]; $offsetX = 0; } } //return values return array('width' => $width, 'height' => $height, 'offsetX' => $offsetX, 'offsetY' => $offsetY); }