@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | |
47 | 47 | /* $Id: font_metrics.cls.php 216 2010-03-11 22:49:18Z ryan.masten $ */ |
48 | 48 | |
49 | -require_once(DOMPDF_LIB_DIR . "/class.pdf.php"); |
|
49 | +require_once(DOMPDF_LIB_DIR."/class.pdf.php"); |
|
50 | 50 | |
51 | 51 | /** |
52 | 52 | * Name of the font cache file |
@@ -59,10 +59,10 @@ discard block |
||
59 | 59 | * |
60 | 60 | * Declared here because PHP5 prevents constants from being declared with expressions |
61 | 61 | */ |
62 | -if (file_exists(DOMPDF_FONT_DIR . "dompdf_font_family_cache")) { |
|
63 | - define('__DOMPDF_FONT_CACHE_FILE', DOMPDF_FONT_DIR . "dompdf_font_family_cache"); |
|
62 | +if (file_exists(DOMPDF_FONT_DIR."dompdf_font_family_cache")) { |
|
63 | + define('__DOMPDF_FONT_CACHE_FILE', DOMPDF_FONT_DIR."dompdf_font_family_cache"); |
|
64 | 64 | } else { |
65 | - define('__DOMPDF_FONT_CACHE_FILE', DOMPDF_FONT_DIR . "dompdf_font_family_cache.dist"); |
|
65 | + define('__DOMPDF_FONT_CACHE_FILE', DOMPDF_FONT_DIR."dompdf_font_family_cache.dist"); |
|
66 | 66 | } |
67 | 67 | |
68 | 68 | |
@@ -157,11 +157,11 @@ discard block |
||
157 | 157 | * Only on checking the fallback font, check various subtypes on same font. |
158 | 158 | */ |
159 | 159 | |
160 | - if ( $family ) { |
|
161 | - $family = str_replace( array("'", '"'), "", mb_strtolower($family)); |
|
160 | + if ($family) { |
|
161 | + $family = str_replace(array("'", '"'), "", mb_strtolower($family)); |
|
162 | 162 | $subtype = mb_strtolower($subtype); |
163 | 163 | |
164 | - if ( isset(self::$_font_lookup[$family][$subtype]) ) { |
|
164 | + if (isset(self::$_font_lookup[$family][$subtype])) { |
|
165 | 165 | return self::$_font_lookup[$family][$subtype]; |
166 | 166 | } |
167 | 167 | return null; |
@@ -169,18 +169,18 @@ discard block |
||
169 | 169 | |
170 | 170 | $family = DOMPDF_DEFAULT_FONT; |
171 | 171 | |
172 | - if ( isset(self::$_font_lookup[$family][$subtype]) ) { |
|
172 | + if (isset(self::$_font_lookup[$family][$subtype])) { |
|
173 | 173 | return self::$_font_lookup[$family][$subtype]; |
174 | 174 | } |
175 | 175 | |
176 | - foreach ( self::$_font_lookup[$family] as $sub => $font ) { |
|
176 | + foreach (self::$_font_lookup[$family] as $sub => $font) { |
|
177 | 177 | if (strpos($subtype, $sub) !== false) { |
178 | 178 | return $font; |
179 | 179 | } |
180 | 180 | } |
181 | 181 | |
182 | 182 | if ($subtype !== "normal") { |
183 | - foreach ( self::$_font_lookup[$family] as $sub => $font ) { |
|
183 | + foreach (self::$_font_lookup[$family] as $sub => $font) { |
|
184 | 184 | if ($sub !== "normal") { |
185 | 185 | return $font; |
186 | 186 | } |
@@ -189,7 +189,7 @@ discard block |
||
189 | 189 | |
190 | 190 | $subtype = "normal"; |
191 | 191 | |
192 | - if ( isset(self::$_font_lookup[$family][$subtype]) ) { |
|
192 | + if (isset(self::$_font_lookup[$family][$subtype])) { |
|
193 | 193 | return self::$_font_lookup[$family][$subtype]; |
194 | 194 | } |
195 | 195 | return null; |
@@ -216,13 +216,13 @@ discard block |
||
216 | 216 | * @see save_font_families() |
217 | 217 | */ |
218 | 218 | static function load_font_families() { |
219 | - if ( !is_readable(self::CACHE_FILE) ) |
|
219 | + if (!is_readable(self::CACHE_FILE)) |
|
220 | 220 | return; |
221 | 221 | |
222 | 222 | $data = file_get_contents(self::CACHE_FILE); |
223 | 223 | |
224 | - if ( $data != "" ) |
|
225 | - eval ('self::$_font_lookup = ' . $data . ";"); |
|
224 | + if ($data != "") |
|
225 | + eval ('self::$_font_lookup = '.$data.";"); |
|
226 | 226 | } |
227 | 227 | |
228 | 228 | /** |
@@ -54,11 +54,11 @@ discard block |
||
54 | 54 | list($x, $y, $w, $h) = $frame->get_padding_box(); |
55 | 55 | |
56 | 56 | // Draw our background, border and content |
57 | - if ( ($bg = $style->background_color) !== "transparent" ) { |
|
58 | - $this->_canvas->filled_rectangle( $x, $y, $w, $h, $style->background_color ); |
|
57 | + if (($bg = $style->background_color) !== "transparent") { |
|
58 | + $this->_canvas->filled_rectangle($x, $y, $w, $h, $style->background_color); |
|
59 | 59 | } |
60 | 60 | |
61 | - if ( ($url = $style->background_image) && $url !== "none" ) |
|
61 | + if (($url = $style->background_image) && $url !== "none") |
|
62 | 62 | $this->_background_image($url, $x, $y, $w, $h, $style); |
63 | 63 | |
64 | 64 | |
@@ -81,11 +81,11 @@ discard block |
||
81 | 81 | foreach ($bp as $side => $props) { |
82 | 82 | list($x, $y, $w, $h) = $bbox; |
83 | 83 | |
84 | - if ( !$props["style"] || $props["style"] === "none" || $props["width"] <= 0 ) |
|
84 | + if (!$props["style"] || $props["style"] === "none" || $props["width"] <= 0) |
|
85 | 85 | continue; |
86 | 86 | |
87 | 87 | |
88 | - switch($side) { |
|
88 | + switch ($side) { |
|
89 | 89 | case "top": |
90 | 90 | $length = $w; |
91 | 91 | break; |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | default: |
107 | 107 | break; |
108 | 108 | } |
109 | - $method = "_border_" . $props["style"]; |
|
109 | + $method = "_border_".$props["style"]; |
|
110 | 110 | |
111 | 111 | $this->$method($x, $y, $length, $props["color"], $widths, $side, $corner_style); |
112 | 112 | } |
@@ -57,15 +57,15 @@ discard block |
||
57 | 57 | |
58 | 58 | function split($frame = null) { |
59 | 59 | |
60 | - if ( is_null($frame) ) { |
|
60 | + if (is_null($frame)) { |
|
61 | 61 | $this->get_parent()->split($this); |
62 | 62 | return; |
63 | 63 | } |
64 | 64 | |
65 | - if ( $frame->get_parent() !== $this ) |
|
65 | + if ($frame->get_parent() !== $this) |
|
66 | 66 | throw new DOMPDF_Exception("Unable to split: frame is not a child of this one."); |
67 | 67 | |
68 | - $split = $this->copy( $this->_frame->get_node()->cloneNode() ); |
|
68 | + $split = $this->copy($this->_frame->get_node()->cloneNode()); |
|
69 | 69 | $this->get_parent()->insert_child_after($split, $this); |
70 | 70 | |
71 | 71 | // Unset the current node's right style properties |
@@ -84,8 +84,8 @@ discard block |
||
84 | 84 | //On continuation of inline element on next line, |
85 | 85 | //don't repeat non-vertically repeatble background images |
86 | 86 | //See e.g. in testcase image_variants, long desriptions |
87 | - if ( ($url = $style->background_image) && $url !== "none" |
|
88 | - && ($repeat = $style->background_repeat) && $repeat !== "repeat" && $repeat !== "repeat-y" |
|
87 | + if (($url = $style->background_image) && $url !== "none" |
|
88 | + && ($repeat = $style->background_repeat) && $repeat !== "repeat" && $repeat !== "repeat-y" |
|
89 | 89 | ) { |
90 | 90 | $style->background_image = "none"; |
91 | 91 | } |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | function render(Frame $frame) { |
80 | 80 | global $_dompdf_debug; |
81 | 81 | |
82 | - if ( $_dompdf_debug ) { |
|
82 | + if ($_dompdf_debug) { |
|
83 | 83 | echo $frame; |
84 | 84 | flush(); |
85 | 85 | } |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | break; |
101 | 101 | |
102 | 102 | case "inline": |
103 | - if ( $frame->get_node()->nodeName === "#text" ) |
|
103 | + if ($frame->get_node()->nodeName === "#text") |
|
104 | 104 | $this->_render_frame("text", $frame); |
105 | 105 | else |
106 | 106 | $this->_render_frame("inline", $frame); |
@@ -121,15 +121,15 @@ discard block |
||
121 | 121 | case "none": |
122 | 122 | $node = $frame->get_node(); |
123 | 123 | |
124 | - if ( $node->nodeName === "script" ) { |
|
125 | - if ( $node->getAttribute("type") === "text/php" || |
|
126 | - $node->getAttribute("language") === "php" ) { |
|
124 | + if ($node->nodeName === "script") { |
|
125 | + if ($node->getAttribute("type") === "text/php" || |
|
126 | + $node->getAttribute("language") === "php") { |
|
127 | 127 | // Evaluate embedded php scripts |
128 | 128 | $this->_render_frame("php", $frame); |
129 | 129 | } |
130 | 130 | |
131 | - elseif ( $node->getAttribute("type") === "text/javascript" || |
|
132 | - $node->getAttribute("language") === "javascript" ) { |
|
131 | + elseif ($node->getAttribute("type") === "text/javascript" || |
|
132 | + $node->getAttribute("language") === "javascript") { |
|
133 | 133 | // Insert JavaScript |
134 | 134 | $this->_render_frame("javascript", $frame); |
135 | 135 | } |
@@ -192,7 +192,7 @@ discard block |
||
192 | 192 | */ |
193 | 193 | protected function _render_frame($type, $frame) { |
194 | 194 | |
195 | - if ( !isset($this->_renderers[$type]) ) { |
|
195 | + if (!isset($this->_renderers[$type])) { |
|
196 | 196 | |
197 | 197 | switch ($type) { |
198 | 198 | case "block": |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | function render(Frame $frame) { |
53 | 53 | $style = $frame->get_style(); |
54 | 54 | |
55 | - if ( !$frame->get_first_child() ) |
|
55 | + if (!$frame->get_first_child()) |
|
56 | 56 | return; // No children, no service |
57 | 57 | |
58 | 58 | // Draw the left border if applicable |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | list($child_x, $child_y, $child_w, $child_h) = $child->get_padding_box(); |
77 | 77 | $child_h += $widths[2]; |
78 | 78 | |
79 | - if ( !is_null($w) && $child_x < $x + $w ) { |
|
79 | + if (!is_null($w) && $child_x < $x + $w) { |
|
80 | 80 | //This branch seems to be supposed to being called on the first part |
81 | 81 | //of an inline html element, and the part after the if clause for the |
82 | 82 | //parts after a line break. |
@@ -87,38 +87,38 @@ discard block |
||
87 | 87 | // borders on this line. |
88 | 88 | |
89 | 89 | // Background: |
90 | - if ( ($bg = $style->background_color) !== "transparent" ) |
|
91 | - $this->_canvas->filled_rectangle( $x, $y, $w, $h, $style->background_color); |
|
90 | + if (($bg = $style->background_color) !== "transparent") |
|
91 | + $this->_canvas->filled_rectangle($x, $y, $w, $h, $style->background_color); |
|
92 | 92 | |
93 | - if ( ($url = $style->background_image) && $url !== "none" ) { |
|
93 | + if (($url = $style->background_image) && $url !== "none") { |
|
94 | 94 | $this->_background_image($url, $x, $y, $w, $h, $style); |
95 | 95 | } |
96 | 96 | |
97 | 97 | // If this is the first row, draw the left border |
98 | - if ( $first_row ) { |
|
98 | + if ($first_row) { |
|
99 | 99 | |
100 | - if ( $bp["left"]["style"] !== "none" && $bp["left"]["width"] > 0 ) { |
|
101 | - $method = "_border_" . $bp["left"]["style"]; |
|
100 | + if ($bp["left"]["style"] !== "none" && $bp["left"]["width"] > 0) { |
|
101 | + $method = "_border_".$bp["left"]["style"]; |
|
102 | 102 | $this->$method($x, $y, $h + $widths[0] + $widths[2], $bp["left"]["color"], $widths, "left"); |
103 | 103 | } |
104 | 104 | $first_row = false; |
105 | 105 | } |
106 | 106 | |
107 | 107 | // Draw the top & bottom borders |
108 | - if ( $bp["top"]["style"] !== "none" && $bp["top"]["width"] > 0 ) { |
|
109 | - $method = "_border_" . $bp["top"]["style"]; |
|
108 | + if ($bp["top"]["style"] !== "none" && $bp["top"]["width"] > 0) { |
|
109 | + $method = "_border_".$bp["top"]["style"]; |
|
110 | 110 | $this->$method($x, $y, $w + $widths[1] + $widths[3], $bp["top"]["color"], $widths, "top"); |
111 | 111 | } |
112 | 112 | |
113 | - if ( $bp["bottom"]["style"] !== "none" && $bp["bottom"]["width"] > 0 ) { |
|
114 | - $method = "_border_" . $bp["bottom"]["style"]; |
|
113 | + if ($bp["bottom"]["style"] !== "none" && $bp["bottom"]["width"] > 0) { |
|
114 | + $method = "_border_".$bp["bottom"]["style"]; |
|
115 | 115 | $this->$method($x, $y + $h + $widths[0] + $widths[2], $w + $widths[1] + $widths[3], $bp["bottom"]["color"], $widths, "bottom"); |
116 | 116 | } |
117 | 117 | |
118 | 118 | // Handle anchors & links |
119 | - if ( $frame->get_node()->nodeName === "a" ) { |
|
119 | + if ($frame->get_node()->nodeName === "a") { |
|
120 | 120 | |
121 | - if ( $href = $frame->get_node()->getAttribute("href") ) |
|
121 | + if ($href = $frame->get_node()->getAttribute("href")) |
|
122 | 122 | $this->_canvas->add_link($href, $x, $y, $w, $h); |
123 | 123 | |
124 | 124 | } |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | continue; |
131 | 131 | } |
132 | 132 | |
133 | - if ( is_null($w) ) |
|
133 | + if (is_null($w)) |
|
134 | 134 | $w = $child_w; |
135 | 135 | else |
136 | 136 | $w += $child_w; |
@@ -140,8 +140,8 @@ discard block |
||
140 | 140 | |
141 | 141 | |
142 | 142 | // Handle the last child |
143 | - if ( ($bg = $style->background_color) !== "transparent" ) |
|
144 | - $this->_canvas->filled_rectangle( $x + $widths[3], $y + $widths[0], $w, $h, $style->background_color); |
|
143 | + if (($bg = $style->background_color) !== "transparent") |
|
144 | + $this->_canvas->filled_rectangle($x + $widths[3], $y + $widths[0], $w, $h, $style->background_color); |
|
145 | 145 | |
146 | 146 | //On continuation lines (after line break) of inline elements, the style got copied. |
147 | 147 | //But a non repeatable background image should not be repeated on the next line. |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | // Repeat not given: default is Style::__construct |
152 | 152 | // ... && (!($repeat = $style->background_repeat) || $repeat === "repeat" ... |
153 | 153 | //different position? $this->_background_image($url, $x, $y, $w, $h, $style); |
154 | - if ( ($url = $style->background_image) && $url !== "none" ) |
|
154 | + if (($url = $style->background_image) && $url !== "none") |
|
155 | 155 | $this->_background_image($url, $x + $widths[3], $y + $widths[0], $w, $h, $style); |
156 | 156 | |
157 | 157 | // Add the border widths |
@@ -163,37 +163,37 @@ discard block |
||
163 | 163 | $x += $left_margin; |
164 | 164 | |
165 | 165 | // If this is the first row, draw the left border too |
166 | - if ( $first_row && $bp["left"]["style"] !== "none" && $widths[3] > 0 ) { |
|
167 | - $method = "_border_" . $bp["left"]["style"]; |
|
166 | + if ($first_row && $bp["left"]["style"] !== "none" && $widths[3] > 0) { |
|
167 | + $method = "_border_".$bp["left"]["style"]; |
|
168 | 168 | $this->$method($x, $y, $h, $bp["left"]["color"], $widths, "left"); |
169 | 169 | } |
170 | 170 | |
171 | 171 | // Draw the top & bottom borders |
172 | - if ( $bp["top"]["style"] !== "none" && $widths[0] > 0 ) { |
|
173 | - $method = "_border_" . $bp["top"]["style"]; |
|
172 | + if ($bp["top"]["style"] !== "none" && $widths[0] > 0) { |
|
173 | + $method = "_border_".$bp["top"]["style"]; |
|
174 | 174 | $this->$method($x, $y, $w, $bp["top"]["color"], $widths, "top"); |
175 | 175 | } |
176 | 176 | |
177 | - if ( $bp["bottom"]["style"] !== "none" && $widths[2] > 0 ) { |
|
178 | - $method = "_border_" . $bp["bottom"]["style"]; |
|
177 | + if ($bp["bottom"]["style"] !== "none" && $widths[2] > 0) { |
|
178 | + $method = "_border_".$bp["bottom"]["style"]; |
|
179 | 179 | $this->$method($x, $y + $h, $w, $bp["bottom"]["color"], $widths, "bottom"); |
180 | 180 | } |
181 | 181 | |
182 | 182 | // pre_var_dump(get_class($frame->get_next_sibling())); |
183 | 183 | // $last_row = get_class($frame->get_next_sibling()) !== 'Inline_Frame_Decorator'; |
184 | 184 | // Draw the right border if this is the last row |
185 | - if ( $bp["right"]["style"] !== "none" && $widths[1] > 0 ) { |
|
186 | - $method = "_border_" . $bp["right"]["style"]; |
|
185 | + if ($bp["right"]["style"] !== "none" && $widths[1] > 0) { |
|
186 | + $method = "_border_".$bp["right"]["style"]; |
|
187 | 187 | $this->$method($x + $w, $y, $h, $bp["right"]["color"], $widths, "right"); |
188 | 188 | } |
189 | 189 | |
190 | 190 | // Handle anchors & links |
191 | - if ( $frame->get_node()->nodeName === "a" ) { |
|
191 | + if ($frame->get_node()->nodeName === "a") { |
|
192 | 192 | |
193 | - if ( $name = $frame->get_node()->getAttribute("name") ) |
|
193 | + if ($name = $frame->get_node()->getAttribute("name")) |
|
194 | 194 | $this->_canvas->add_named_dest($name); |
195 | 195 | |
196 | - if ( $href = $frame->get_node()->getAttribute("href") ) |
|
196 | + if ($href = $frame->get_node()->getAttribute("href")) |
|
197 | 197 | $this->_canvas->add_link($href, $x, $y, $w, $h); |
198 | 198 | } |
199 | 199 | } |
@@ -90,8 +90,8 @@ discard block |
||
90 | 90 | // Resample the bullet image to be consistent with 'auto' sized images |
91 | 91 | // See also Image_Frame_Reflower::get_min_max_width |
92 | 92 | // Tested php ver: value measured in px, suffix "px" not in value: rtrim unnecessary. |
93 | - $this->_width = (((float)rtrim($width, "px")) * 72) / DOMPDF_DPI; |
|
94 | - $this->_height = (((float)rtrim($height, "px")) * 72) / DOMPDF_DPI; |
|
93 | + $this->_width = (((float) rtrim($width, "px")) * 72) / DOMPDF_DPI; |
|
94 | + $this->_height = (((float) rtrim($height, "px")) * 72) / DOMPDF_DPI; |
|
95 | 95 | |
96 | 96 | //If an image is taller as the containing block/box, the box should be extended. |
97 | 97 | //Neighbour elements are overwriting the overlapping image areas. |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | //for proper alignment of bullet image and text. Allow image to not fitting on left border. |
117 | 117 | //This controls the distance between bullet image and text |
118 | 118 | //return $this->_width; |
119 | - return $this->_frame->get_style()->get_font_size()*List_Bullet_Frame_Decorator::BULLET_SIZE + |
|
119 | + return $this->_frame->get_style()->get_font_size() * List_Bullet_Frame_Decorator::BULLET_SIZE + |
|
120 | 120 | 2 * List_Bullet_Frame_Decorator::BULLET_PADDING; |
121 | 121 | } |
122 | 122 | |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | |
146 | 146 | // Small hack to prevent indenting of list text |
147 | 147 | // Image Might not exist, then position like on list_bullet_frame_decorator fallback to none. |
148 | - if ( $this->_frame->get_style()->list_style_position === "outside" || |
|
148 | + if ($this->_frame->get_style()->list_style_position === "outside" || |
|
149 | 149 | $this->_width == 0) |
150 | 150 | return 0; |
151 | 151 | //This aligns the "inside" image position with the text. |
@@ -54,14 +54,14 @@ discard block |
||
54 | 54 | |
55 | 55 | static function decorate_root(Frame $root, DOMPDF $dompdf) { |
56 | 56 | $frame = new Page_Frame_Decorator($root, $dompdf); |
57 | - $frame->set_reflower( new Page_Frame_Reflower($frame) ); |
|
57 | + $frame->set_reflower(new Page_Frame_Reflower($frame)); |
|
58 | 58 | $root->set_decorator($frame); |
59 | 59 | return $frame; |
60 | 60 | } |
61 | 61 | |
62 | 62 | // FIXME: this is admittedly a little smelly... |
63 | 63 | static function decorate_frame(Frame $frame, $dompdf) { |
64 | - if ( is_null($dompdf) ) |
|
64 | + if (is_null($dompdf)) |
|
65 | 65 | throw new Exception("foo"); |
66 | 66 | switch ($frame->get_style()->display) { |
67 | 67 | |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | |
80 | 80 | case "inline": |
81 | 81 | $positioner = "Inline"; |
82 | - if ( $frame->get_node()->nodeName === "#text" ) { |
|
82 | + if ($frame->get_node()->nodeName === "#text") { |
|
83 | 83 | $decorator = "Text"; |
84 | 84 | $reflower = "Text"; |
85 | 85 | } else { |
@@ -127,12 +127,12 @@ discard block |
||
127 | 127 | break; |
128 | 128 | |
129 | 129 | case "-dompdf-list-bullet": |
130 | - if ( $frame->get_style()->list_style_position === "inside" ) |
|
130 | + if ($frame->get_style()->list_style_position === "inside") |
|
131 | 131 | $positioner = "Inline"; |
132 | 132 | else |
133 | 133 | $positioner = "List_Bullet"; |
134 | 134 | |
135 | - if ( $frame->get_style()->list_style_image !== "none" ) |
|
135 | + if ($frame->get_style()->list_style_image !== "none") |
|
136 | 136 | $decorator = "List_Bullet_Image"; |
137 | 137 | else |
138 | 138 | $decorator = "List_Bullet"; |
@@ -162,8 +162,8 @@ discard block |
||
162 | 162 | |
163 | 163 | } |
164 | 164 | |
165 | - if ( $frame->get_style()->position === "absolute" || |
|
166 | - $frame->get_style()->position === "fixed" ) |
|
165 | + if ($frame->get_style()->position === "absolute" || |
|
166 | + $frame->get_style()->position === "fixed") |
|
167 | 167 | $positioner = "Absolute"; |
168 | 168 | |
169 | 169 | $positioner .= "_Positioner"; |
@@ -171,18 +171,18 @@ discard block |
||
171 | 171 | $reflower .= "_Frame_Reflower"; |
172 | 172 | |
173 | 173 | $deco = new $decorator($frame, $dompdf); |
174 | - $deco->set_positioner( new $positioner($deco) ); |
|
174 | + $deco->set_positioner(new $positioner($deco)); |
|
175 | 175 | $reflow = new $reflower($deco); |
176 | 176 | |
177 | 177 | // Generated content is a special case |
178 | - if ( $frame->get_node()->nodeName === "_dompdf_generated" ) { |
|
178 | + if ($frame->get_node()->nodeName === "_dompdf_generated") { |
|
179 | 179 | // Decorate the reflower |
180 | - $gen = new Generated_Frame_Reflower( $deco ); |
|
181 | - $gen->set_reflower( $reflow ); |
|
180 | + $gen = new Generated_Frame_Reflower($deco); |
|
181 | + $gen->set_reflower($reflow); |
|
182 | 182 | $reflow = $gen; |
183 | 183 | } |
184 | 184 | |
185 | - $deco->set_reflower( $reflow ); |
|
185 | + $deco->set_reflower($reflow); |
|
186 | 186 | |
187 | 187 | // Images are a special case |
188 | 188 | // if ( $frame->get_node()->nodeName === "img" ) { |
@@ -101,8 +101,8 @@ discard block |
||
101 | 101 | */ |
102 | 102 | function dispose($recursive = false) { |
103 | 103 | |
104 | - if ( $recursive ) { |
|
105 | - while ( $child = $this->get_first_child() ) |
|
104 | + if ($recursive) { |
|
105 | + while ($child = $this->get_first_child()) |
|
106 | 106 | $child->dispose(true); |
107 | 107 | } |
108 | 108 | |
@@ -183,41 +183,41 @@ discard block |
||
183 | 183 | function __toString() { return $this->_frame->__toString(); } |
184 | 184 | |
185 | 185 | function prepend_child(Frame $child, $update_node = true) { |
186 | - while ( $child instanceof Frame_Decorator ) |
|
186 | + while ($child instanceof Frame_Decorator) |
|
187 | 187 | $child = $child->_frame; |
188 | 188 | |
189 | 189 | $this->_frame->prepend_child($child, $update_node); |
190 | 190 | } |
191 | 191 | |
192 | 192 | function append_child(Frame $child, $update_node = true) { |
193 | - while ( $child instanceof Frame_Decorator ) |
|
193 | + while ($child instanceof Frame_Decorator) |
|
194 | 194 | $child = $child->_frame; |
195 | 195 | |
196 | 196 | $this->_frame->append_child($child, $update_node); |
197 | 197 | } |
198 | 198 | |
199 | 199 | function insert_child_before(Frame $new_child, Frame $ref, $update_node = true) { |
200 | - while ( $new_child instanceof Frame_Decorator ) |
|
200 | + while ($new_child instanceof Frame_Decorator) |
|
201 | 201 | $new_child = $new_child->_frame; |
202 | 202 | |
203 | - if ( $ref instanceof Frame_Decorator ) |
|
203 | + if ($ref instanceof Frame_Decorator) |
|
204 | 204 | $ref = $ref->_frame; |
205 | 205 | |
206 | 206 | $this->_frame->insert_child_before($new_child, $ref, $update_node); |
207 | 207 | } |
208 | 208 | |
209 | 209 | function insert_child_after(Frame $new_child, Frame $ref, $update_node = true) { |
210 | - while ( $new_child instanceof Frame_Decorator ) |
|
210 | + while ($new_child instanceof Frame_Decorator) |
|
211 | 211 | $new_child = $new_child->_frame; |
212 | 212 | |
213 | - while ( $ref instanceof Frame_Decorator ) |
|
213 | + while ($ref instanceof Frame_Decorator) |
|
214 | 214 | $ref = $ref->_frame; |
215 | 215 | |
216 | 216 | $this->_frame->insert_child_after($new_child, $ref, $update_node); |
217 | 217 | } |
218 | 218 | |
219 | 219 | function remove_child(Frame $child, $update_node = true) { |
220 | - while ( $child instanceof Frame_Decorator ) |
|
220 | + while ($child instanceof Frame_Decorator) |
|
221 | 221 | $child = $new_child->_frame; |
222 | 222 | |
223 | 223 | $this->_frame->remove_child($child, $update_node); |
@@ -229,11 +229,11 @@ discard block |
||
229 | 229 | |
230 | 230 | $p = $this->_frame->get_parent(); |
231 | 231 | |
232 | - if ( $p && $deco = $p->get_decorator() ) { |
|
233 | - while ( $tmp = $deco->get_decorator() ) |
|
232 | + if ($p && $deco = $p->get_decorator()) { |
|
233 | + while ($tmp = $deco->get_decorator()) |
|
234 | 234 | $deco = $tmp; |
235 | 235 | return $deco; |
236 | - } else if ( $p ) |
|
236 | + } else if ($p) |
|
237 | 237 | return $p; |
238 | 238 | else |
239 | 239 | return null; |
@@ -241,11 +241,11 @@ discard block |
||
241 | 241 | |
242 | 242 | function get_first_child() { |
243 | 243 | $c = $this->_frame->get_first_child(); |
244 | - if ( $c && $deco = $c->get_decorator() ) { |
|
245 | - while ( $tmp = $deco->get_decorator() ) |
|
244 | + if ($c && $deco = $c->get_decorator()) { |
|
245 | + while ($tmp = $deco->get_decorator()) |
|
246 | 246 | $deco = $tmp; |
247 | 247 | return $deco; |
248 | - } else if ( $c ) |
|
248 | + } else if ($c) |
|
249 | 249 | return $c; |
250 | 250 | else |
251 | 251 | return null; |
@@ -253,11 +253,11 @@ discard block |
||
253 | 253 | |
254 | 254 | function get_last_child() { |
255 | 255 | $c = $this->_frame->get_last_child(); |
256 | - if ( $c && $deco = $c->get_decorator() ) { |
|
257 | - while ( $tmp = $deco->get_decorator() ) |
|
256 | + if ($c && $deco = $c->get_decorator()) { |
|
257 | + while ($tmp = $deco->get_decorator()) |
|
258 | 258 | $deco = $tmp; |
259 | 259 | return $deco; |
260 | - } else if ( $c ) |
|
260 | + } else if ($c) |
|
261 | 261 | return $c; |
262 | 262 | else |
263 | 263 | return null; |
@@ -265,11 +265,11 @@ discard block |
||
265 | 265 | |
266 | 266 | function get_prev_sibling() { |
267 | 267 | $s = $this->_frame->get_prev_sibling(); |
268 | - if ( $s && $deco = $s->get_decorator() ) { |
|
269 | - while ( $tmp = $deco->get_decorator() ) |
|
268 | + if ($s && $deco = $s->get_decorator()) { |
|
269 | + while ($tmp = $deco->get_decorator()) |
|
270 | 270 | $deco = $tmp; |
271 | 271 | return $deco; |
272 | - } else if ( $s ) |
|
272 | + } else if ($s) |
|
273 | 273 | return $s; |
274 | 274 | else |
275 | 275 | return null; |
@@ -277,11 +277,11 @@ discard block |
||
277 | 277 | |
278 | 278 | function get_next_sibling() { |
279 | 279 | $s = $this->_frame->get_next_sibling(); |
280 | - if ( $s && $deco = $s->get_decorator() ) { |
|
281 | - while ( $tmp = $deco->get_decorator() ) |
|
280 | + if ($s && $deco = $s->get_decorator()) { |
|
281 | + while ($tmp = $deco->get_decorator()) |
|
282 | 282 | $deco = $tmp; |
283 | 283 | return $deco; |
284 | - } else if ( $s ) |
|
284 | + } else if ($s) |
|
285 | 285 | return $s; |
286 | 286 | else |
287 | 287 | return null; |
@@ -299,7 +299,7 @@ discard block |
||
299 | 299 | |
300 | 300 | function set_positioner(Positioner $posn) { |
301 | 301 | $this->_positioner = $posn; |
302 | - if ( $this->_frame instanceof Frame_Decorator ) |
|
302 | + if ($this->_frame instanceof Frame_Decorator) |
|
303 | 303 | $this->_frame->set_positioner($posn); |
304 | 304 | } |
305 | 305 | |
@@ -307,8 +307,8 @@ discard block |
||
307 | 307 | |
308 | 308 | function set_reflower(Frame_Reflower $reflower) { |
309 | 309 | $this->_reflower = $reflower; |
310 | - if ( $this->_frame instanceof Frame_Decorator ) |
|
311 | - $this->_frame->set_reflower( $reflower ); |
|
310 | + if ($this->_frame instanceof Frame_Decorator) |
|
311 | + $this->_frame->set_reflower($reflower); |
|
312 | 312 | } |
313 | 313 | |
314 | 314 | function get_reflower() { return $this->_reflower; } |
@@ -317,7 +317,7 @@ discard block |
||
317 | 317 | |
318 | 318 | function set_root(Frame $root) { |
319 | 319 | $this->_root = $root; |
320 | - if ( $this->_frame instanceof Frame_Decorator ) |
|
320 | + if ($this->_frame instanceof Frame_Decorator) |
|
321 | 321 | $this->_frame->set_root($root); |
322 | 322 | } |
323 | 323 | |
@@ -330,8 +330,8 @@ discard block |
||
330 | 330 | // Find our nearest block level parent |
331 | 331 | $p = $this->get_parent(); |
332 | 332 | |
333 | - while ( $p ) { |
|
334 | - if ( in_array($p->get_style()->display, Style::$BLOCK_TYPES) ) |
|
333 | + while ($p) { |
|
334 | + if (in_array($p->get_style()->display, Style::$BLOCK_TYPES)) |
|
335 | 335 | break; |
336 | 336 | |
337 | 337 | $p = $p->get_parent(); |
@@ -353,15 +353,15 @@ discard block |
||
353 | 353 | */ |
354 | 354 | function split($child = null) { |
355 | 355 | |
356 | - if ( is_null( $child ) ) { |
|
356 | + if (is_null($child)) { |
|
357 | 357 | $this->get_parent()->split($this); |
358 | 358 | return; |
359 | 359 | } |
360 | 360 | |
361 | - if ( $child->get_parent() !== $this ) |
|
361 | + if ($child->get_parent() !== $this) |
|
362 | 362 | throw new DOMPDF_Exception("Unable to split: frame is not a child of this one."); |
363 | 363 | |
364 | - $split = $this->copy( $this->_frame->get_node()->cloneNode() ); |
|
364 | + $split = $this->copy($this->_frame->get_node()->cloneNode()); |
|
365 | 365 | $split->reset(); |
366 | 366 | $this->get_parent()->insert_child_after($split, $this); |
367 | 367 | |
@@ -379,7 +379,7 @@ discard block |
||
379 | 379 | |
380 | 380 | //........................................................................ |
381 | 381 | |
382 | - final function position() { $this->_positioner->position(); } |
|
382 | + final function position() { $this->_positioner->position(); } |
|
383 | 383 | |
384 | 384 | final function reflow() { |
385 | 385 | // Uncomment this to see the frames before they're laid out, instead of |
@@ -54,17 +54,17 @@ discard block |
||
54 | 54 | */ |
55 | 55 | class Text_Renderer extends Abstract_Renderer { |
56 | 56 | |
57 | - const DECO_THICKNESS = 0.04; // Thickness of underline. Screen: 0.08, print: better less, e.g. 0.04 |
|
57 | + const DECO_THICKNESS = 0.04; // Thickness of underline. Screen: 0.08, print: better less, e.g. 0.04 |
|
58 | 58 | |
59 | 59 | //Tweaking if $base and $descent are not accurate. |
60 | 60 | //Check method_exists( $this->_canvas, "get_cpdf" ) |
61 | 61 | //- For cpdf these can and must stay 0, because font metrics are used directly. |
62 | 62 | //- For other renderers, if different values are wanted, separate the parameter sets. |
63 | 63 | // But $size and $size-$height seem to be accurate enough |
64 | - const UNDERLINE_OFFSET = 0.0; // Relative to bottom of text, as fraction of height. |
|
65 | - const OVERLINE_OFFSET = 0.0; // Relative to top of text |
|
64 | + const UNDERLINE_OFFSET = 0.0; // Relative to bottom of text, as fraction of height. |
|
65 | + const OVERLINE_OFFSET = 0.0; // Relative to top of text |
|
66 | 66 | const LINETHROUGH_OFFSET = 0.0; // Relative to centre of text. |
67 | - const DECO_EXTENSION = 0.0; // How far to extend lines past either end, in pt |
|
67 | + const DECO_EXTENSION = 0.0; // How far to extend lines past either end, in pt |
|
68 | 68 | |
69 | 69 | //........................................................................ |
70 | 70 | |
@@ -74,16 +74,16 @@ discard block |
||
74 | 74 | list($x, $y) = $frame->get_position(); |
75 | 75 | $cb = $frame->get_containing_block(); |
76 | 76 | |
77 | - if ( ($ml = $style->margin_left) === "auto" || $ml === "none" ) |
|
77 | + if (($ml = $style->margin_left) === "auto" || $ml === "none") |
|
78 | 78 | $ml = 0; |
79 | 79 | |
80 | - if ( ($pl = $style->padding_left) === "auto" || $pl === "none" ) |
|
80 | + if (($pl = $style->padding_left) === "auto" || $pl === "none") |
|
81 | 81 | $pl = 0; |
82 | 82 | |
83 | - if ( ($bl = $style->border_left_width) === "auto" || $bl === "none" ) |
|
83 | + if (($bl = $style->border_left_width) === "auto" || $bl === "none") |
|
84 | 84 | $bl = 0; |
85 | 85 | |
86 | - $x += $style->length_in_pt( array($ml, $pl, $bl), $cb["w"] ); |
|
86 | + $x += $style->length_in_pt(array($ml, $pl, $bl), $cb["w"]); |
|
87 | 87 | |
88 | 88 | $text = $frame->get_text(); |
89 | 89 | |
@@ -99,15 +99,15 @@ discard block |
||
99 | 99 | $font, $size, |
100 | 100 | $style->color, $spacing); |
101 | 101 | |
102 | - if ( method_exists( $this->_canvas, "get_cpdf" ) ) { |
|
103 | - $base = ($this->_canvas->get_cpdf()->fonts[$this->_canvas->get_cpdf()->currentFont]['FontBBox'][3]*$size)/1000; |
|
104 | - $descent = ($this->_canvas->get_cpdf()->fonts[$this->_canvas->get_cpdf()->currentFont]['FontBBox'][1]*$size)/1000; |
|
102 | + if (method_exists($this->_canvas, "get_cpdf")) { |
|
103 | + $base = ($this->_canvas->get_cpdf()->fonts[$this->_canvas->get_cpdf()->currentFont]['FontBBox'][3] * $size) / 1000; |
|
104 | + $descent = ($this->_canvas->get_cpdf()->fonts[$this->_canvas->get_cpdf()->currentFont]['FontBBox'][1] * $size) / 1000; |
|
105 | 105 | //print '<pre>Text_Renderer cpdf:'.$base.' '.$descent.' '.$size.'</pre>'; |
106 | 106 | } else { |
107 | 107 | //Descent is font part below baseline, typically negative. $height is about full height of font box. |
108 | 108 | //$descent = -$size/6; is less accurate, depends on font family. |
109 | 109 | $base = $size; |
110 | - $descent = $size-$height; |
|
110 | + $descent = $size - $height; |
|
111 | 111 | //print '<pre>Text_Renderer other than cpdf:'.$base.' '.$descent.' '.$size.'</pre>'; |
112 | 112 | } |
113 | 113 | |
@@ -118,14 +118,14 @@ discard block |
||
118 | 118 | // our way down. |
119 | 119 | $p = $frame; |
120 | 120 | $stack = array(); |
121 | - while ( $p = $p->get_parent() ) |
|
121 | + while ($p = $p->get_parent()) |
|
122 | 122 | $stack[] = $p; |
123 | 123 | |
124 | - while ( count($stack) > 0 ) { |
|
124 | + while (count($stack) > 0) { |
|
125 | 125 | $f = array_pop($stack); |
126 | 126 | |
127 | 127 | $deco_y = $y; |
128 | - if ( ($text_deco = $f->get_style()->text_decoration) === "none" ) |
|
128 | + if (($text_deco = $f->get_style()->text_decoration) === "none") |
|
129 | 129 | continue; |
130 | 130 | |
131 | 131 | $color = $f->get_style()->color; |
@@ -136,11 +136,11 @@ discard block |
||
136 | 136 | continue; |
137 | 137 | |
138 | 138 | case "underline": |
139 | - $deco_y += $base - $descent+ $size * (self::UNDERLINE_OFFSET - self::DECO_THICKNESS/2); |
|
139 | + $deco_y += $base - $descent + $size * (self::UNDERLINE_OFFSET - self::DECO_THICKNESS / 2); |
|
140 | 140 | break; |
141 | 141 | |
142 | 142 | case "overline": |
143 | - $deco_y += $size * (self::OVERLINE_OFFSET + self::DECO_THICKNESS/2); |
|
143 | + $deco_y += $size * (self::OVERLINE_OFFSET + self::DECO_THICKNESS / 2); |
|
144 | 144 | break; |
145 | 145 | |
146 | 146 | case "line-through": |