Example #1
0
 public function test_convertSize()
 {
     $this->assertEquals(1, Style::convertSize(1));
     $this->assertEquals(10, Style::convertSize("10px"));
     // FIXME
     $this->assertEquals(10, Style::convertSize("10pt"));
     $this->assertEquals(8, Style::convertSize("80%", 72, 10));
 }
Example #2
0
 public function handleSizeAttributes($attributes)
 {
     if ($this->width === null) {
         if (isset($attributes["width"])) {
             $width = Style::convertSize($attributes["width"], 400);
             $this->width = $width;
         }
         if (isset($attributes["height"])) {
             $height = Style::convertSize($attributes["height"], 300);
             $this->height = $height;
         }
         if (isset($attributes['viewbox'])) {
             $viewBox = preg_split('/[\\s,]+/is', trim($attributes['viewbox']));
             if (count($viewBox) == 4) {
                 $this->x = $viewBox[0];
                 $this->y = $viewBox[1];
                 if (!$this->width) {
                     $this->width = $viewBox[2];
                 }
                 if (!$this->height) {
                     $this->height = $viewBox[3];
                 }
             }
         }
     }
     return array(0 => $this->width, 1 => $this->height, "width" => $this->width, "height" => $this->height);
 }