Ejemplo n.º 1
0
 /**
  * Tests the static utf8_to_entities method.
  */
 public function test_utf8_to_entities()
 {
     $str = "Žluťoučký koníček©"&<>§«";
     $this->assertSame("Žluťoučký koníček©"&<>§«", core_text::utf8_to_entities($str));
     $this->assertSame("Žluťoučký koníček©"&<>§«", core_text::utf8_to_entities($str, true));
     $str = "Žluťoučký koníček©"&<>§«";
     $this->assertSame("&#x17d;lu&#x165;ou&#x10d;k&#xfd; kon&#xed;&#x10d;ek&#xa9;\"&<>&#xa7;&#xab;", core_text::utf8_to_entities($str, false, true));
     $this->assertSame("&#381;lu&#357;ou&#269;k&#253; kon&#237;&#269;ek&#169;\"&<>&#167;&#171;", core_text::utf8_to_entities($str, true, true));
 }
Ejemplo n.º 2
0
 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 = core_text::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);
 }