Test Failed
Branch master (20b14b)
by Marcio
04:20
created
src/Ballybran/Library/fpdf/font/courier.php 1 patch
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -18,8 +18,9 @@
 block discarded – undo
18 18
 $name = 'Courier';
19 19
 $up = -100;
20 20
 $ut = 50;
21
-for ($i = 0; $i <= 255; $i++)
22
-    $cw[chr($i)] = 600;
21
+for ($i = 0; $i <= 255; $i++) {
22
+    $cw[chr($i)] = 600;
23
+}
23 24
 $enc = 'cp1252';
24 25
 $uv = array(0 => array(0, 128), 128 => 8364, 130 => 8218, 131 => 402, 132 => 8222, 133 => 8230, 134 => array(8224, 2), 136 => 710, 137 => 8240, 138 => 352, 139 => 8249, 140 => 338, 142 => 381, 145 => array(8216, 2), 147 => array(8220, 2), 149 => 8226, 150 => array(8211, 2), 152 => 732, 153 => 8482, 154 => 353, 155 => 8250, 156 => 339, 158 => 382, 159 => 376, 160 => array(160, 96));
25 26
 ?>
Please login to merge, or discard this patch.
src/Ballybran/Library/fpdf/font/courierbi.php 1 patch
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -18,8 +18,9 @@
 block discarded – undo
18 18
 $name = 'Courier-BoldOblique';
19 19
 $up = -100;
20 20
 $ut = 50;
21
-for ($i = 0; $i <= 255; $i++)
22
-    $cw[chr($i)] = 600;
21
+for ($i = 0; $i <= 255; $i++) {
22
+    $cw[chr($i)] = 600;
23
+}
23 24
 $enc = 'cp1252';
24 25
 $uv = array(0 => array(0, 128), 128 => 8364, 130 => 8218, 131 => 402, 132 => 8222, 133 => 8230, 134 => array(8224, 2), 136 => 710, 137 => 8240, 138 => 352, 139 => 8249, 140 => 338, 142 => 381, 145 => array(8216, 2), 147 => array(8220, 2), 149 => 8226, 150 => array(8211, 2), 152 => 732, 153 => 8482, 154 => 353, 155 => 8250, 156 => 339, 158 => 382, 159 => 376, 160 => array(160, 96));
25 26
 ?>
Please login to merge, or discard this patch.
src/Ballybran/Library/fpdf/font/courieri.php 1 patch
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -18,8 +18,9 @@
 block discarded – undo
18 18
 $name = 'Courier-Oblique';
19 19
 $up = -100;
20 20
 $ut = 50;
21
-for ($i = 0; $i <= 255; $i++)
22
-    $cw[chr($i)] = 600;
21
+for ($i = 0; $i <= 255; $i++) {
22
+    $cw[chr($i)] = 600;
23
+}
23 24
 $enc = 'cp1252';
24 25
 $uv = array(0 => array(0, 128), 128 => 8364, 130 => 8218, 131 => 402, 132 => 8222, 133 => 8230, 134 => array(8224, 2), 136 => 710, 137 => 8240, 138 => 352, 139 => 8249, 140 => 338, 142 => 381, 145 => array(8216, 2), 147 => array(8220, 2), 149 => 8226, 150 => array(8211, 2), 152 => 732, 153 => 8482, 154 => 353, 155 => 8250, 156 => 339, 158 => 382, 159 => 376, 160 => array(160, 96));
25 26
 ?>
Please login to merge, or discard this patch.
src/Ballybran/Library/fpdf/font/courierb.php 1 patch
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -18,8 +18,9 @@
 block discarded – undo
18 18
 $name = 'Courier-Bold';
19 19
 $up = -100;
20 20
 $ut = 50;
21
-for ($i = 0; $i <= 255; $i++)
22
-    $cw[chr($i)] = 600;
21
+for ($i = 0; $i <= 255; $i++) {
22
+    $cw[chr($i)] = 600;
23
+}
23 24
 $enc = 'cp1252';
24 25
 $uv = array(0 => array(0, 128), 128 => 8364, 130 => 8218, 131 => 402, 132 => 8222, 133 => 8230, 134 => array(8224, 2), 136 => 710, 137 => 8240, 138 => 352, 139 => 8249, 140 => 338, 142 => 381, 145 => array(8216, 2), 147 => array(8220, 2), 149 => 8226, 150 => array(8211, 2), 152 => 732, 153 => 8482, 154 => 353, 155 => 8250, 156 => 339, 158 => 382, 159 => 376, 160 => array(160, 96));
25 26
 ?>
Please login to merge, or discard this patch.
src/Ballybran/Library/fpdf/fpdf.php 2 patches
Spacing   +58 added lines, -58 removed lines patch added patch discarded remove patch
@@ -29,61 +29,61 @@  discard block
 block discarded – undo
29 29
 class FPDF
30 30
 {
31 31
 
32
-    protected $page;               // current page number
33
-    protected $n;                  // current object number
34
-    protected $offsets;            // array of object offsets
35
-    protected $buffer;             // buffer holding in-memory PDF
36
-    protected $pages;              // array containing pages
37
-    protected $state;              // current document state
38
-    protected $compress;           // compression flag
39
-    protected $k;                  // scale factor (number of points in user unit)
40
-    protected $DefOrientation;     // default orientation
41
-    protected $CurOrientation;     // current orientation
42
-    protected $StdPageSizes;       // standard page sizes
43
-    protected $DefPageSize;        // default page size
44
-    protected $CurPageSize;        // current page size
45
-    protected $CurRotation;        // current page rotation
46
-    protected $PageInfo;           // page-related data
47
-    protected $wPt, $hPt;          // dimensions of current page in points
48
-    protected $w, $h;              // dimensions of current page in user unit
49
-    protected $lMargin;            // left margin
50
-    protected $tMargin;            // top margin
51
-    protected $rMargin;            // right margin
52
-    protected $bMargin;            // page break margin
53
-    protected $cMargin;            // cell margin
54
-    protected $x, $y;              // current position in user unit
55
-    protected $lasth;              // height of last printed cell
56
-    protected $LineWidth;          // line width in user unit
57
-    protected $fontpath;           // path containing fonts
58
-    protected $CoreFonts;          // array of core font names
59
-    protected $fonts;              // array of used fonts
60
-    protected $FontFiles;          // array of font files
61
-    protected $encodings;          // array of encodings
62
-    protected $cmaps;              // array of ToUnicode CMaps
63
-    protected $FontFamily;         // current font family
64
-    protected $FontStyle;          // current font style
65
-    protected $underline;          // underlining flag
66
-    protected $CurrentFont;        // current font info
67
-    protected $FontSizePt;         // current font size in points
68
-    protected $FontSize;           // current font size in user unit
69
-    protected $DrawColor;          // commands for drawing color
70
-    protected $FillColor;          // commands for filling color
71
-    protected $TextColor;          // commands for text color
72
-    protected $ColorFlag;          // indicates whether fill and text colors are different
73
-    protected $WithAlpha;          // indicates whether alpha channel is used
74
-    protected $ws;                 // word spacing
75
-    protected $images;             // array of used images
76
-    protected $PageLinks;          // array of links in pages
77
-    protected $links;              // array of internal links
78
-    protected $AutoPageBreak;      // automatic page breaking
79
-    protected $PageBreakTrigger;   // threshold used to trigger page breaks
80
-    protected $InHeader;           // flag set when processing header
81
-    protected $InFooter;           // flag set when processing footer
82
-    protected $AliasNbPages;       // alias for total number of pages
83
-    protected $ZoomMode;           // zoom display mode
84
-    protected $LayoutMode;         // layout display mode
85
-    protected $metadata;           // document properties
86
-    protected $PDFVersion;         // PDF version number
32
+    protected $page; // current page number
33
+    protected $n; // current object number
34
+    protected $offsets; // array of object offsets
35
+    protected $buffer; // buffer holding in-memory PDF
36
+    protected $pages; // array containing pages
37
+    protected $state; // current document state
38
+    protected $compress; // compression flag
39
+    protected $k; // scale factor (number of points in user unit)
40
+    protected $DefOrientation; // default orientation
41
+    protected $CurOrientation; // current orientation
42
+    protected $StdPageSizes; // standard page sizes
43
+    protected $DefPageSize; // default page size
44
+    protected $CurPageSize; // current page size
45
+    protected $CurRotation; // current page rotation
46
+    protected $PageInfo; // page-related data
47
+    protected $wPt, $hPt; // dimensions of current page in points
48
+    protected $w, $h; // dimensions of current page in user unit
49
+    protected $lMargin; // left margin
50
+    protected $tMargin; // top margin
51
+    protected $rMargin; // right margin
52
+    protected $bMargin; // page break margin
53
+    protected $cMargin; // cell margin
54
+    protected $x, $y; // current position in user unit
55
+    protected $lasth; // height of last printed cell
56
+    protected $LineWidth; // line width in user unit
57
+    protected $fontpath; // path containing fonts
58
+    protected $CoreFonts; // array of core font names
59
+    protected $fonts; // array of used fonts
60
+    protected $FontFiles; // array of font files
61
+    protected $encodings; // array of encodings
62
+    protected $cmaps; // array of ToUnicode CMaps
63
+    protected $FontFamily; // current font family
64
+    protected $FontStyle; // current font style
65
+    protected $underline; // underlining flag
66
+    protected $CurrentFont; // current font info
67
+    protected $FontSizePt; // current font size in points
68
+    protected $FontSize; // current font size in user unit
69
+    protected $DrawColor; // commands for drawing color
70
+    protected $FillColor; // commands for filling color
71
+    protected $TextColor; // commands for text color
72
+    protected $ColorFlag; // indicates whether fill and text colors are different
73
+    protected $WithAlpha; // indicates whether alpha channel is used
74
+    protected $ws; // word spacing
75
+    protected $images; // array of used images
76
+    protected $PageLinks; // array of links in pages
77
+    protected $links; // array of internal links
78
+    protected $AutoPageBreak; // automatic page breaking
79
+    protected $PageBreakTrigger; // threshold used to trigger page breaks
80
+    protected $InHeader; // flag set when processing header
81
+    protected $InFooter; // flag set when processing footer
82
+    protected $AliasNbPages; // alias for total number of pages
83
+    protected $ZoomMode; // zoom display mode
84
+    protected $LayoutMode; // layout display mode
85
+    protected $metadata; // document properties
86
+    protected $PDFVersion; // PDF version number
87 87
 
88 88
     /*     * *****************************************************************************
89 89
      *                               Public methods                                 *
@@ -484,14 +484,14 @@  discard block
 block discarded – undo
484 484
         else
485 485
             $family = strtolower($family);
486 486
         $style = strtoupper($style);
487
-        if ( false !== strpos($style, 'U') ) {
487
+        if (false !== strpos($style, 'U')) {
488 488
             $this->underline = true;
489 489
             $style = str_replace('U', '', $style);
490 490
         } else
491 491
             $this->underline = false;
492
-        if ( 'IB' == $style )
492
+        if ('IB' == $style)
493 493
             $style = 'BI';
494
-        if ( 0 == $size )
494
+        if (0 == $size)
495 495
             $size = $this->FontSizePt;
496 496
         // Test if font is already selected
497 497
         if ($this->FontFamily == $family && $this->FontStyle == $style && $this->FontSizePt == $size)
Please login to merge, or discard this patch.
Braces   +613 added lines, -441 removed lines patch added patch discarded remove patch
@@ -122,25 +122,28 @@  discard block
 block discarded – undo
122 122
         // Font path
123 123
         if (defined('FPDF_FONTPATH')) {
124 124
             $this->fontpath = FPDF_FONTPATH;
125
-            if (substr($this->fontpath, -1) != '/' && substr($this->fontpath, -1) != '\\')
126
-                $this->fontpath .= '/';
127
-        } elseif (is_dir(dirname(__FILE__) . '/font'))
128
-            $this->fontpath = dirname(__FILE__) . '/font/';
129
-        else
130
-            $this->fontpath = '';
125
+            if (substr($this->fontpath, -1) != '/' && substr($this->fontpath, -1) != '\\') {
126
+                            $this->fontpath .= '/';
127
+            }
128
+        } elseif (is_dir(dirname(__FILE__) . '/font')) {
129
+                    $this->fontpath = dirname(__FILE__) . '/font/';
130
+        } else {
131
+                    $this->fontpath = '';
132
+        }
131 133
         // Core fonts
132 134
         $this->CoreFonts = array('courier', 'helvetica', 'times', 'symbol', 'zapfdingbats');
133 135
         // Scale factor
134
-        if ($unit == 'pt')
135
-            $this->k = 1;
136
-        elseif ($unit == 'mm')
137
-            $this->k = 72 / 25.4;
138
-        elseif ($unit == 'cm')
139
-            $this->k = 72 / 2.54;
140
-        elseif ($unit == 'in')
141
-            $this->k = 72;
142
-        else
143
-            $this->Error('Incorrect unit: ' . $unit);
136
+        if ($unit == 'pt') {
137
+                    $this->k = 1;
138
+        } elseif ($unit == 'mm') {
139
+                    $this->k = 72 / 25.4;
140
+        } elseif ($unit == 'cm') {
141
+                    $this->k = 72 / 2.54;
142
+        } elseif ($unit == 'in') {
143
+                    $this->k = 72;
144
+        } else {
145
+                    $this->Error('Incorrect unit: ' . $unit);
146
+        }
144 147
         // Page sizes
145 148
         $this->StdPageSizes = array('a3' => array(841.89, 1190.55), 'a4' => array(595.28, 841.89), 'a5' => array(420.94, 595.28),
146 149
             'letter' => array(612, 792), 'legal' => array(612, 1008));
@@ -157,8 +160,9 @@  discard block
 block discarded – undo
157 160
             $this->DefOrientation = 'L';
158 161
             $this->w = $size[1];
159 162
             $this->h = $size[0];
160
-        } else
161
-            $this->Error('Incorrect orientation: ' . $orientation);
163
+        } else {
164
+                    $this->Error('Incorrect orientation: ' . $orientation);
165
+        }
162 166
         $this->CurOrientation = $this->DefOrientation;
163 167
         $this->wPt = $this->w * $this->k;
164 168
         $this->hPt = $this->h * $this->k;
@@ -186,8 +190,9 @@  discard block
 block discarded – undo
186 190
         // Set left, top and right margins
187 191
         $this->lMargin = $left;
188 192
         $this->tMargin = $top;
189
-        if ($right === null)
190
-            $right = $left;
193
+        if ($right === null) {
194
+                    $right = $left;
195
+        }
191 196
         $this->rMargin = $right;
192 197
     }
193 198
 
@@ -195,8 +200,9 @@  discard block
 block discarded – undo
195 200
     {
196 201
         // Set left margin
197 202
         $this->lMargin = $margin;
198
-        if ($this->page > 0 && $this->x < $margin)
199
-            $this->x = $margin;
203
+        if ($this->page > 0 && $this->x < $margin) {
204
+                    $this->x = $margin;
205
+        }
200 206
     }
201 207
 
202 208
     function SetTopMargin($margin)
@@ -222,23 +228,26 @@  discard block
 block discarded – undo
222 228
     function SetDisplayMode($zoom, $layout = 'default')
223 229
     {
224 230
         // Set display mode in viewer
225
-        if ($zoom == 'fullpage' || $zoom == 'fullwidth' || $zoom == 'real' || $zoom == 'default' || !is_string($zoom))
226
-            $this->ZoomMode = $zoom;
227
-        else
228
-            $this->Error('Incorrect zoom display mode: ' . $zoom);
229
-        if ($layout == 'single' || $layout == 'continuous' || $layout == 'two' || $layout == 'default')
230
-            $this->LayoutMode = $layout;
231
-        else
232
-            $this->Error('Incorrect layout display mode: ' . $layout);
231
+        if ($zoom == 'fullpage' || $zoom == 'fullwidth' || $zoom == 'real' || $zoom == 'default' || !is_string($zoom)) {
232
+                    $this->ZoomMode = $zoom;
233
+        } else {
234
+                    $this->Error('Incorrect zoom display mode: ' . $zoom);
235
+        }
236
+        if ($layout == 'single' || $layout == 'continuous' || $layout == 'two' || $layout == 'default') {
237
+                    $this->LayoutMode = $layout;
238
+        } else {
239
+                    $this->Error('Incorrect layout display mode: ' . $layout);
240
+        }
233 241
     }
234 242
 
235 243
     function SetCompression($compress)
236 244
     {
237 245
         // Set page compression
238
-        if (function_exists('gzcompress'))
239
-            $this->compress = $compress;
240
-        else
241
-            $this->compress = false;
246
+        if (function_exists('gzcompress')) {
247
+                    $this->compress = $compress;
248
+        } else {
249
+                    $this->compress = false;
250
+        }
242 251
     }
243 252
 
244 253
     function SetTitle($title, $isUTF8 = false)
@@ -286,10 +295,12 @@  discard block
 block discarded – undo
286 295
     function Close()
287 296
     {
288 297
         // Terminate document
289
-        if ($this->state == 3)
290
-            return;
291
-        if ($this->page == 0)
292
-            $this->AddPage();
298
+        if ($this->state == 3) {
299
+                    return;
300
+        }
301
+        if ($this->page == 0) {
302
+                    $this->AddPage();
303
+        }
293 304
         // Page footer
294 305
         $this->InFooter = true;
295 306
         $this->Footer();
@@ -303,8 +314,9 @@  discard block
 block discarded – undo
303 314
     function AddPage($orientation = '', $size = '', $rotation = 0)
304 315
     {
305 316
         // Start a new page
306
-        if ($this->state == 3)
307
-            $this->Error('The document is closed');
317
+        if ($this->state == 3) {
318
+                    $this->Error('The document is closed');
319
+        }
308 320
         $family = $this->FontFamily;
309 321
         $style = $this->FontStyle . ($this->underline ? 'U' : '');
310 322
         $fontsize = $this->FontSizePt;
@@ -329,15 +341,18 @@  discard block
 block discarded – undo
329 341
         $this->LineWidth = $lw;
330 342
         $this->_out(sprintf('%.2F w', $lw * $this->k));
331 343
         // Set font
332
-        if ($family)
333
-            $this->SetFont($family, $style, $fontsize);
344
+        if ($family) {
345
+                    $this->SetFont($family, $style, $fontsize);
346
+        }
334 347
         // Set colors
335 348
         $this->DrawColor = $dc;
336
-        if ($dc != '0 G')
337
-            $this->_out($dc);
349
+        if ($dc != '0 G') {
350
+                    $this->_out($dc);
351
+        }
338 352
         $this->FillColor = $fc;
339
-        if ($fc != '0 g')
340
-            $this->_out($fc);
353
+        if ($fc != '0 g') {
354
+                    $this->_out($fc);
355
+        }
341 356
         $this->TextColor = $tc;
342 357
         $this->ColorFlag = $cf;
343 358
         // Page header
@@ -350,8 +365,9 @@  discard block
 block discarded – undo
350 365
             $this->_out(sprintf('%.2F w', $lw * $this->k));
351 366
         }
352 367
         // Restore font
353
-        if ($family)
354
-            $this->SetFont($family, $style, $fontsize);
368
+        if ($family) {
369
+                    $this->SetFont($family, $style, $fontsize);
370
+        }
355 371
         // Restore colors
356 372
         if ($this->DrawColor != $dc) {
357 373
             $this->DrawColor = $dc;
@@ -384,33 +400,38 @@  discard block
 block discarded – undo
384 400
     function SetDrawColor($r, $g = null, $b = null)
385 401
     {
386 402
         // Set color for all stroking operations
387
-        if (($r == 0 && $g == 0 && $b == 0) || $g === null)
388
-            $this->DrawColor = sprintf('%.3F G', $r / 255);
389
-        else
390
-            $this->DrawColor = sprintf('%.3F %.3F %.3F RG', $r / 255, $g / 255, $b / 255);
391
-        if ($this->page > 0)
392
-            $this->_out($this->DrawColor);
403
+        if (($r == 0 && $g == 0 && $b == 0) || $g === null) {
404
+                    $this->DrawColor = sprintf('%.3F G', $r / 255);
405
+        } else {
406
+                    $this->DrawColor = sprintf('%.3F %.3F %.3F RG', $r / 255, $g / 255, $b / 255);
407
+        }
408
+        if ($this->page > 0) {
409
+                    $this->_out($this->DrawColor);
410
+        }
393 411
     }
394 412
 
395 413
     function SetFillColor($r, $g = null, $b = null)
396 414
     {
397 415
         // Set color for all filling operations
398
-        if (($r == 0 && $g == 0 && $b == 0) || $g === null)
399
-            $this->FillColor = sprintf('%.3F g', $r / 255);
400
-        else
401
-            $this->FillColor = sprintf('%.3F %.3F %.3F rg', $r / 255, $g / 255, $b / 255);
416
+        if (($r == 0 && $g == 0 && $b == 0) || $g === null) {
417
+                    $this->FillColor = sprintf('%.3F g', $r / 255);
418
+        } else {
419
+                    $this->FillColor = sprintf('%.3F %.3F %.3F rg', $r / 255, $g / 255, $b / 255);
420
+        }
402 421
         $this->ColorFlag = ($this->FillColor != $this->TextColor);
403
-        if ($this->page > 0)
404
-            $this->_out($this->FillColor);
422
+        if ($this->page > 0) {
423
+                    $this->_out($this->FillColor);
424
+        }
405 425
     }
406 426
 
407 427
     function SetTextColor($r, $g = null, $b = null)
408 428
     {
409 429
         // Set color for text
410
-        if (($r == 0 && $g == 0 && $b == 0) || $g === null)
411
-            $this->TextColor = sprintf('%.3F g', $r / 255);
412
-        else
413
-            $this->TextColor = sprintf('%.3F %.3F %.3F rg', $r / 255, $g / 255, $b / 255);
430
+        if (($r == 0 && $g == 0 && $b == 0) || $g === null) {
431
+                    $this->TextColor = sprintf('%.3F g', $r / 255);
432
+        } else {
433
+                    $this->TextColor = sprintf('%.3F %.3F %.3F rg', $r / 255, $g / 255, $b / 255);
434
+        }
414 435
         $this->ColorFlag = ($this->FillColor != $this->TextColor);
415 436
     }
416 437
 
@@ -421,8 +442,9 @@  discard block
 block discarded – undo
421 442
         $cw = &$this->CurrentFont['cw'];
422 443
         $w = 0;
423 444
         $l = strlen($s);
424
-        for ($i = 0; $i < $l; $i++)
425
-            $w += $cw[$s[$i]];
445
+        for ($i = 0; $i < $l; $i++) {
446
+                    $w += $cw[$s[$i]];
447
+        }
426 448
         return $w * $this->FontSize / 1000;
427 449
     }
428 450
 
@@ -430,8 +452,9 @@  discard block
 block discarded – undo
430 452
     {
431 453
         // Set line width
432 454
         $this->LineWidth = $width;
433
-        if ($this->page > 0)
434
-            $this->_out(sprintf('%.2F w', $width * $this->k));
455
+        if ($this->page > 0) {
456
+                    $this->_out(sprintf('%.2F w', $width * $this->k));
457
+        }
435 458
     }
436 459
 
437 460
     function Line($x1, $y1, $x2, $y2)
@@ -443,12 +466,13 @@  discard block
 block discarded – undo
443 466
     function Rect($x, $y, $w, $h, $style = '')
444 467
     {
445 468
         // Draw a rectangle
446
-        if ($style == 'F')
447
-            $op = 'f';
448
-        elseif ($style == 'FD' || $style == 'DF')
449
-            $op = 'B';
450
-        else
451
-            $op = 'S';
469
+        if ($style == 'F') {
470
+                    $op = 'f';
471
+        } elseif ($style == 'FD' || $style == 'DF') {
472
+                    $op = 'B';
473
+        } else {
474
+                    $op = 'S';
475
+        }
452 476
         $this->_out(sprintf('%.2F %.2F %.2F %.2F re %s', $x * $this->k, ($this->h - $y) * $this->k, $w * $this->k, -$h * $this->k, $op));
453 477
     }
454 478
 
@@ -456,22 +480,26 @@  discard block
 block discarded – undo
456 480
     {
457 481
         // Add a TrueType, OpenType or Type1 font
458 482
         $family = strtolower($family);
459
-        if ($file == '')
460
-            $file = str_replace(' ', '', $family) . strtolower($style) . '.php';
483
+        if ($file == '') {
484
+                    $file = str_replace(' ', '', $family) . strtolower($style) . '.php';
485
+        }
461 486
         $style = strtoupper($style);
462
-        if ($style == 'IB')
463
-            $style = 'BI';
487
+        if ($style == 'IB') {
488
+                    $style = 'BI';
489
+        }
464 490
         $fontkey = $family . $style;
465
-        if (isset($this->fonts[$fontkey]))
466
-            return;
491
+        if (isset($this->fonts[$fontkey])) {
492
+                    return;
493
+        }
467 494
         $info = $this->_loadfont($file);
468 495
         $info['i'] = count($this->fonts) + 1;
469 496
         if (!empty($info['file'])) {
470 497
             // Embedded font
471
-            if ($info['type'] == 'TrueType')
472
-                $this->FontFiles[$info['file']] = array('length1' => $info['originalsize']);
473
-            else
474
-                $this->FontFiles[$info['file']] = array('length1' => $info['size1'], 'length2' => $info['size2']);
498
+            if ($info['type'] == 'TrueType') {
499
+                            $this->FontFiles[$info['file']] = array('length1' => $info['originalsize']);
500
+            } else {
501
+                            $this->FontFiles[$info['file']] = array('length1' => $info['size1'], 'length2' => $info['size2']);
502
+            }
475 503
         }
476 504
         $this->fonts[$fontkey] = $info;
477 505
     }
@@ -479,37 +507,46 @@  discard block
 block discarded – undo
479 507
     function SetFont($family, $style = '', $size = 0)
480 508
     {
481 509
         // Select a font; size given in points
482
-        if ($family == '')
483
-            $family = $this->FontFamily;
484
-        else
485
-            $family = strtolower($family);
510
+        if ($family == '') {
511
+                    $family = $this->FontFamily;
512
+        } else {
513
+                    $family = strtolower($family);
514
+        }
486 515
         $style = strtoupper($style);
487 516
         if ( false !== strpos($style, 'U') ) {
488 517
             $this->underline = true;
489 518
             $style = str_replace('U', '', $style);
490
-        } else
491
-            $this->underline = false;
492
-        if ( 'IB' == $style )
493
-            $style = 'BI';
494
-        if ( 0 == $size )
495
-            $size = $this->FontSizePt;
519
+        } else {
520
+                    $this->underline = false;
521
+        }
522
+        if ( 'IB' == $style ) {
523
+                    $style = 'BI';
524
+        }
525
+        if ( 0 == $size ) {
526
+                    $size = $this->FontSizePt;
527
+        }
496 528
         // Test if font is already selected
497
-        if ($this->FontFamily == $family && $this->FontStyle == $style && $this->FontSizePt == $size)
498
-            return;
529
+        if ($this->FontFamily == $family && $this->FontStyle == $style && $this->FontSizePt == $size) {
530
+                    return;
531
+        }
499 532
         // Test if font is already loaded
500 533
         $fontkey = $family . $style;
501 534
         if (!isset($this->fonts[$fontkey])) {
502 535
             // Test if one of the core fonts
503
-            if ($family == 'arial')
504
-                $family = 'helvetica';
536
+            if ($family == 'arial') {
537
+                            $family = 'helvetica';
538
+            }
505 539
             if (in_array($family, $this->CoreFonts)) {
506
-                if ($family == 'symbol' || $family == 'zapfdingbats')
507
-                    $style = '';
540
+                if ($family == 'symbol' || $family == 'zapfdingbats') {
541
+                                    $style = '';
542
+                }
508 543
                 $fontkey = $family . $style;
509
-                if (!isset($this->fonts[$fontkey]))
510
-                    $this->AddFont($family, $style);
511
-            } else
512
-                $this->Error('Undefined font: ' . $family . ' ' . $style);
544
+                if (!isset($this->fonts[$fontkey])) {
545
+                                    $this->AddFont($family, $style);
546
+                }
547
+            } else {
548
+                            $this->Error('Undefined font: ' . $family . ' ' . $style);
549
+            }
513 550
         }
514 551
         // Select it
515 552
         $this->FontFamily = $family;
@@ -517,19 +554,22 @@  discard block
 block discarded – undo
517 554
         $this->FontSizePt = $size;
518 555
         $this->FontSize = $size / $this->k;
519 556
         $this->CurrentFont = &$this->fonts[$fontkey];
520
-        if ($this->page > 0)
521
-            $this->_out(sprintf('BT /F%d %.2F Tf ET', $this->CurrentFont['i'], $this->FontSizePt));
557
+        if ($this->page > 0) {
558
+                    $this->_out(sprintf('BT /F%d %.2F Tf ET', $this->CurrentFont['i'], $this->FontSizePt));
559
+        }
522 560
     }
523 561
 
524 562
     function SetFontSize($size)
525 563
     {
526 564
         // Set font size in points
527
-        if ($this->FontSizePt == $size)
528
-            return;
565
+        if ($this->FontSizePt == $size) {
566
+                    return;
567
+        }
529 568
         $this->FontSizePt = $size;
530 569
         $this->FontSize = $size / $this->k;
531
-        if ($this->page > 0)
532
-            $this->_out(sprintf('BT /F%d %.2F Tf ET', $this->CurrentFont['i'], $this->FontSizePt));
570
+        if ($this->page > 0) {
571
+                    $this->_out(sprintf('BT /F%d %.2F Tf ET', $this->CurrentFont['i'], $this->FontSizePt));
572
+        }
533 573
     }
534 574
 
535 575
     function AddLink()
@@ -543,10 +583,12 @@  discard block
 block discarded – undo
543 583
     function SetLink($link, $y = 0, $page = -1)
544 584
     {
545 585
         // Set destination of internal link
546
-        if ($y == -1)
547
-            $y = $this->y;
548
-        if ($page == -1)
549
-            $page = $this->page;
586
+        if ($y == -1) {
587
+                    $y = $this->y;
588
+        }
589
+        if ($page == -1) {
590
+                    $page = $this->page;
591
+        }
550 592
         $this->links[$link] = array($page, $y);
551 593
     }
552 594
 
@@ -559,13 +601,16 @@  discard block
 block discarded – undo
559 601
     function Text($x, $y, $txt)
560 602
     {
561 603
         // Output a string
562
-        if (!isset($this->CurrentFont))
563
-            $this->Error('No font has been set');
604
+        if (!isset($this->CurrentFont)) {
605
+                    $this->Error('No font has been set');
606
+        }
564 607
         $s = sprintf('BT %.2F %.2F Td (%s) Tj ET', $x * $this->k, ($this->h - $y) * $this->k, $this->_escape($txt));
565
-        if ($this->underline && $txt != '')
566
-            $s .= ' ' . $this->_dounderline($x, $y, $txt);
567
-        if ($this->ColorFlag)
568
-            $s = 'q ' . $this->TextColor . ' ' . $s . ' Q';
608
+        if ($this->underline && $txt != '') {
609
+                    $s .= ' ' . $this->_dounderline($x, $y, $txt);
610
+        }
611
+        if ($this->ColorFlag) {
612
+                    $s = 'q ' . $this->TextColor . ' ' . $s . ' Q';
613
+        }
569 614
         $this->_out($s);
570 615
     }
571 616
 
@@ -594,72 +639,90 @@  discard block
 block discarded – undo
594 639
                 $this->_out(sprintf('%.3F Tw', $ws * $k));
595 640
             }
596 641
         }
597
-        if ($w == 0)
598
-            $w = $this->w - $this->rMargin - $this->x;
642
+        if ($w == 0) {
643
+                    $w = $this->w - $this->rMargin - $this->x;
644
+        }
599 645
         $s = '';
600 646
         if ($fill || $border == 1) {
601
-            if ($fill)
602
-                $op = ($border == 1) ? 'B' : 'f';
603
-            else
604
-                $op = 'S';
647
+            if ($fill) {
648
+                            $op = ($border == 1) ? 'B' : 'f';
649
+            } else {
650
+                            $op = 'S';
651
+            }
605 652
             $s = sprintf('%.2F %.2F %.2F %.2F re %s ', $this->x * $k, ($this->h - $this->y) * $k, $w * $k, -$h * $k, $op);
606 653
         }
607 654
         if (is_string($border)) {
608 655
             $x = $this->x;
609 656
             $y = $this->y;
610
-            if (strpos($border, 'L') !== false)
611
-                $s .= sprintf('%.2F %.2F m %.2F %.2F l S ', $x * $k, ($this->h - $y) * $k, $x * $k, ($this->h - ($y + $h)) * $k);
612
-            if (strpos($border, 'T') !== false)
613
-                $s .= sprintf('%.2F %.2F m %.2F %.2F l S ', $x * $k, ($this->h - $y) * $k, ($x + $w) * $k, ($this->h - $y) * $k);
614
-            if (strpos($border, 'R') !== false)
615
-                $s .= sprintf('%.2F %.2F m %.2F %.2F l S ', ($x + $w) * $k, ($this->h - $y) * $k, ($x + $w) * $k, ($this->h - ($y + $h)) * $k);
616
-            if (strpos($border, 'B') !== false)
617
-                $s .= sprintf('%.2F %.2F m %.2F %.2F l S ', $x * $k, ($this->h - ($y + $h)) * $k, ($x + $w) * $k, ($this->h - ($y + $h)) * $k);
657
+            if (strpos($border, 'L') !== false) {
658
+                            $s .= sprintf('%.2F %.2F m %.2F %.2F l S ', $x * $k, ($this->h - $y) * $k, $x * $k, ($this->h - ($y + $h)) * $k);
659
+            }
660
+            if (strpos($border, 'T') !== false) {
661
+                            $s .= sprintf('%.2F %.2F m %.2F %.2F l S ', $x * $k, ($this->h - $y) * $k, ($x + $w) * $k, ($this->h - $y) * $k);
662
+            }
663
+            if (strpos($border, 'R') !== false) {
664
+                            $s .= sprintf('%.2F %.2F m %.2F %.2F l S ', ($x + $w) * $k, ($this->h - $y) * $k, ($x + $w) * $k, ($this->h - ($y + $h)) * $k);
665
+            }
666
+            if (strpos($border, 'B') !== false) {
667
+                            $s .= sprintf('%.2F %.2F m %.2F %.2F l S ', $x * $k, ($this->h - ($y + $h)) * $k, ($x + $w) * $k, ($this->h - ($y + $h)) * $k);
668
+            }
618 669
         }
619 670
         if ($txt !== '') {
620
-            if (!isset($this->CurrentFont))
621
-                $this->Error('No font has been set');
622
-            if ($align == 'R')
623
-                $dx = $w - $this->cMargin - $this->GetStringWidth($txt);
624
-            elseif ($align == 'C')
625
-                $dx = ($w - $this->GetStringWidth($txt)) / 2;
626
-            else
627
-                $dx = $this->cMargin;
628
-            if ($this->ColorFlag)
629
-                $s .= 'q ' . $this->TextColor . ' ';
671
+            if (!isset($this->CurrentFont)) {
672
+                            $this->Error('No font has been set');
673
+            }
674
+            if ($align == 'R') {
675
+                            $dx = $w - $this->cMargin - $this->GetStringWidth($txt);
676
+            } elseif ($align == 'C') {
677
+                            $dx = ($w - $this->GetStringWidth($txt)) / 2;
678
+            } else {
679
+                            $dx = $this->cMargin;
680
+            }
681
+            if ($this->ColorFlag) {
682
+                            $s .= 'q ' . $this->TextColor . ' ';
683
+            }
630 684
             $s .= sprintf('BT %.2F %.2F Td (%s) Tj ET', ($this->x + $dx) * $k, ($this->h - ($this->y + .5 * $h + .3 * $this->FontSize)) * $k, $this->_escape($txt));
631
-            if ($this->underline)
632
-                $s .= ' ' . $this->_dounderline($this->x + $dx, $this->y + .5 * $h + .3 * $this->FontSize, $txt);
633
-            if ($this->ColorFlag)
634
-                $s .= ' Q';
635
-            if ($link)
636
-                $this->Link($this->x + $dx, $this->y + .5 * $h - .5 * $this->FontSize, $this->GetStringWidth($txt), $this->FontSize, $link);
685
+            if ($this->underline) {
686
+                            $s .= ' ' . $this->_dounderline($this->x + $dx, $this->y + .5 * $h + .3 * $this->FontSize, $txt);
687
+            }
688
+            if ($this->ColorFlag) {
689
+                            $s .= ' Q';
690
+            }
691
+            if ($link) {
692
+                            $this->Link($this->x + $dx, $this->y + .5 * $h - .5 * $this->FontSize, $this->GetStringWidth($txt), $this->FontSize, $link);
693
+            }
637 694
         }
638
-        if ($s)
639
-            $this->_out($s);
695
+        if ($s) {
696
+                    $this->_out($s);
697
+        }
640 698
         $this->lasth = $h;
641 699
         if ($ln > 0) {
642 700
             // Go to next line
643 701
             $this->y += $h;
644
-            if ($ln == 1)
645
-                $this->x = $this->lMargin;
646
-        } else
647
-            $this->x += $w;
702
+            if ($ln == 1) {
703
+                            $this->x = $this->lMargin;
704
+            }
705
+        } else {
706
+                    $this->x += $w;
707
+        }
648 708
     }
649 709
 
650 710
     function MultiCell($w, $h, $txt, $border = 0, $align = 'J', $fill = false)
651 711
     {
652 712
         // Output text with automatic or explicit line breaks
653
-        if (!isset($this->CurrentFont))
654
-            $this->Error('No font has been set');
713
+        if (!isset($this->CurrentFont)) {
714
+                    $this->Error('No font has been set');
715
+        }
655 716
         $cw = &$this->CurrentFont['cw'];
656
-        if ($w == 0)
657
-            $w = $this->w - $this->rMargin - $this->x;
717
+        if ($w == 0) {
718
+                    $w = $this->w - $this->rMargin - $this->x;
719
+        }
658 720
         $wmax = ($w - 2 * $this->cMargin) * 1000 / $this->FontSize;
659 721
         $s = str_replace("\r", '', $txt);
660 722
         $nb = strlen($s);
661
-        if ($nb > 0 && $s[$nb - 1] == "\n")
662
-            $nb--;
723
+        if ($nb > 0 && $s[$nb - 1] == "\n") {
724
+                    $nb--;
725
+        }
663 726
         $b = 0;
664 727
         if ($border) {
665 728
             if ($border == 1) {
@@ -668,10 +731,12 @@  discard block
 block discarded – undo
668 731
                 $b2 = 'LR';
669 732
             } else {
670 733
                 $b2 = '';
671
-                if (strpos($border, 'L') !== false)
672
-                    $b2 .= 'L';
673
-                if (strpos($border, 'R') !== false)
674
-                    $b2 .= 'R';
734
+                if (strpos($border, 'L') !== false) {
735
+                                    $b2 .= 'L';
736
+                }
737
+                if (strpos($border, 'R') !== false) {
738
+                                    $b2 .= 'R';
739
+                }
675 740
                 $b = (strpos($border, 'T') !== false) ? $b2 . 'T' : $b2;
676 741
             }
677 742
         }
@@ -697,8 +762,9 @@  discard block
 block discarded – undo
697 762
                 $l = 0;
698 763
                 $ns = 0;
699 764
                 $nl++;
700
-                if ($border && $nl == 2)
701
-                    $b = $b2;
765
+                if ($border && $nl == 2) {
766
+                                    $b = $b2;
767
+                }
702 768
                 continue;
703 769
             }
704 770
             if ($c == ' ') {
@@ -710,8 +776,9 @@  discard block
 block discarded – undo
710 776
             if ($l > $wmax) {
711 777
                 // Automatic line break
712 778
                 if ($sep == -1) {
713
-                    if ($i == $j)
714
-                        $i++;
779
+                    if ($i == $j) {
780
+                                            $i++;
781
+                    }
715 782
                     if ($this->ws > 0) {
716 783
                         $this->ws = 0;
717 784
                         $this->_out('0 Tw');
@@ -730,18 +797,21 @@  discard block
 block discarded – undo
730 797
                 $l = 0;
731 798
                 $ns = 0;
732 799
                 $nl++;
733
-                if ($border && $nl == 2)
734
-                    $b = $b2;
735
-            } else
736
-                $i++;
800
+                if ($border && $nl == 2) {
801
+                                    $b = $b2;
802
+                }
803
+            } else {
804
+                            $i++;
805
+            }
737 806
         }
738 807
         // Last chunk
739 808
         if ($this->ws > 0) {
740 809
             $this->ws = 0;
741 810
             $this->_out('0 Tw');
742 811
         }
743
-        if ($border && strpos($border, 'B') !== false)
744
-            $b .= 'B';
812
+        if ($border && strpos($border, 'B') !== false) {
813
+                    $b .= 'B';
814
+        }
745 815
         $this->Cell($w, $h, substr($s, $j, $i - $j), $b, 2, $align, $fill);
746 816
         $this->x = $this->lMargin;
747 817
     }
@@ -749,8 +819,9 @@  discard block
 block discarded – undo
749 819
     function Write($h, $txt, $link = '')
750 820
     {
751 821
         // Output text in flowing mode
752
-        if (!isset($this->CurrentFont))
753
-            $this->Error('No font has been set');
822
+        if (!isset($this->CurrentFont)) {
823
+                    $this->Error('No font has been set');
824
+        }
754 825
         $cw = &$this->CurrentFont['cw'];
755 826
         $w = $this->w - $this->rMargin - $this->x;
756 827
         $wmax = ($w - 2 * $this->cMargin) * 1000 / $this->FontSize;
@@ -779,8 +850,9 @@  discard block
 block discarded – undo
779 850
                 $nl++;
780 851
                 continue;
781 852
             }
782
-            if ($c == ' ')
783
-                $sep = $i;
853
+            if ($c == ' ') {
854
+                            $sep = $i;
855
+            }
784 856
             $l += $cw[$c];
785 857
             if ($l > $wmax) {
786 858
                 // Automatic line break
@@ -795,8 +867,9 @@  discard block
 block discarded – undo
795 867
                         $nl++;
796 868
                         continue;
797 869
                     }
798
-                    if ($i == $j)
799
-                        $i++;
870
+                    if ($i == $j) {
871
+                                            $i++;
872
+                    }
800 873
                     $this->Cell($w, $h, substr($s, $j, $i - $j), 0, 2, '', false, $link);
801 874
                 } else {
802 875
                     $this->Cell($w, $h, substr($s, $j, $sep - $j), 0, 2, '', false, $link);
@@ -811,48 +884,56 @@  discard block
 block discarded – undo
811 884
                     $wmax = ($w - 2 * $this->cMargin) * 1000 / $this->FontSize;
812 885
                 }
813 886
                 $nl++;
814
-            } else
815
-                $i++;
887
+            } else {
888
+                            $i++;
889
+            }
816 890
         }
817 891
         // Last chunk
818
-        if ($i != $j)
819
-            $this->Cell($l / 1000 * $this->FontSize, $h, substr($s, $j), 0, 0, '', false, $link);
892
+        if ($i != $j) {
893
+                    $this->Cell($l / 1000 * $this->FontSize, $h, substr($s, $j), 0, 0, '', false, $link);
894
+        }
820 895
     }
821 896
 
822 897
     function Ln($h = null)
823 898
     {
824 899
         // Line feed; default value is the last cell height
825 900
         $this->x = $this->lMargin;
826
-        if ($h === null)
827
-            $this->y += $this->lasth;
828
-        else
829
-            $this->y += $h;
901
+        if ($h === null) {
902
+                    $this->y += $this->lasth;
903
+        } else {
904
+                    $this->y += $h;
905
+        }
830 906
     }
831 907
 
832 908
     function Image($file, $x = null, $y = null, $w = 0, $h = 0, $type = '', $link = '')
833 909
     {
834 910
         // Put an image on the page
835
-        if ($file == '')
836
-            $this->Error('Image file name is empty');
911
+        if ($file == '') {
912
+                    $this->Error('Image file name is empty');
913
+        }
837 914
         if (!isset($this->images[$file])) {
838 915
             // First use of this image, get info
839 916
             if ($type == '') {
840 917
                 $pos = strrpos($file, '.');
841
-                if (!$pos)
842
-                    $this->Error('Image file has no extension and no type was specified: ' . $file);
918
+                if (!$pos) {
919
+                                    $this->Error('Image file has no extension and no type was specified: ' . $file);
920
+                }
843 921
                 $type = substr($file, $pos + 1);
844 922
             }
845 923
             $type = strtolower($type);
846
-            if ($type == 'jpeg')
847
-                $type = 'jpg';
924
+            if ($type == 'jpeg') {
925
+                            $type = 'jpg';
926
+            }
848 927
             $mtd = '_parse' . $type;
849
-            if (!method_exists($this, $mtd))
850
-                $this->Error('Unsupported image type: ' . $type);
928
+            if (!method_exists($this, $mtd)) {
929
+                            $this->Error('Unsupported image type: ' . $type);
930
+            }
851 931
             $info = $this->$mtd($file);
852 932
             $info['i'] = count($this->images) + 1;
853 933
             $this->images[$file] = $info;
854
-        } else
855
-            $info = $this->images[$file];
934
+        } else {
935
+                    $info = $this->images[$file];
936
+        }
856 937
 
857 938
         // Automatic width and height calculation if needed
858 939
         if ($w == 0 && $h == 0) {
@@ -860,14 +941,18 @@  discard block
 block discarded – undo
860 941
             $w = -96;
861 942
             $h = -96;
862 943
         }
863
-        if ($w < 0)
864
-            $w = -$info['w'] * 72 / $w / $this->k;
865
-        if ($h < 0)
866
-            $h = -$info['h'] * 72 / $h / $this->k;
867
-        if ($w == 0)
868
-            $w = $h * $info['w'] / $info['h'];
869
-        if ($h == 0)
870
-            $h = $w * $info['h'] / $info['w'];
944
+        if ($w < 0) {
945
+                    $w = -$info['w'] * 72 / $w / $this->k;
946
+        }
947
+        if ($h < 0) {
948
+                    $h = -$info['h'] * 72 / $h / $this->k;
949
+        }
950
+        if ($w == 0) {
951
+                    $w = $h * $info['w'] / $info['h'];
952
+        }
953
+        if ($h == 0) {
954
+                    $h = $w * $info['h'] / $info['w'];
955
+        }
871 956
 
872 957
         // Flowing mode
873 958
         if ($y === null) {
@@ -881,11 +966,13 @@  discard block
 block discarded – undo
881 966
             $this->y += $h;
882 967
         }
883 968
 
884
-        if ($x === null)
885
-            $x = $this->x;
969
+        if ($x === null) {
970
+                    $x = $this->x;
971
+        }
886 972
         $this->_out(sprintf('q %.2F 0 0 %.2F %.2F %.2F cm /I%d Do Q', $w * $this->k, $h * $this->k, $x * $this->k, ($this->h - ($y + $h)) * $this->k, $info['i']));
887
-        if ($link)
888
-            $this->Link($x, $y, $w, $h, $link);
973
+        if ($link) {
974
+                    $this->Link($x, $y, $w, $h, $link);
975
+        }
889 976
     }
890 977
 
891 978
     function GetPageWidth()
@@ -909,10 +996,11 @@  discard block
 block discarded – undo
909 996
     function SetX($x)
910 997
     {
911 998
         // Set x position
912
-        if ($x >= 0)
913
-            $this->x = $x;
914
-        else
915
-            $this->x = $this->w + $x;
999
+        if ($x >= 0) {
1000
+                    $this->x = $x;
1001
+        } else {
1002
+                    $this->x = $this->w + $x;
1003
+        }
916 1004
     }
917 1005
 
918 1006
     function GetY()
@@ -924,12 +1012,14 @@  discard block
 block discarded – undo
924 1012
     function SetY($y, $resetX = true)
925 1013
     {
926 1014
         // Set y position and optionally reset x
927
-        if ($y >= 0)
928
-            $this->y = $y;
929
-        else
930
-            $this->y = $this->h + $y;
931
-        if ($resetX)
932
-            $this->x = $this->lMargin;
1015
+        if ($y >= 0) {
1016
+                    $this->y = $y;
1017
+        } else {
1018
+                    $this->y = $this->h + $y;
1019
+        }
1020
+        if ($resetX) {
1021
+                    $this->x = $this->lMargin;
1022
+        }
933 1023
     }
934 1024
 
935 1025
     function SetXY($x, $y)
@@ -949,10 +1039,12 @@  discard block
 block discarded – undo
949 1039
             $dest = $name;
950 1040
             $name = $tmp;
951 1041
         }
952
-        if ($dest == '')
953
-            $dest = 'I';
954
-        if ($name == '')
955
-            $name = 'doc.pdf';
1042
+        if ($dest == '') {
1043
+                    $dest = 'I';
1044
+        }
1045
+        if ($name == '') {
1046
+                    $name = 'doc.pdf';
1047
+        }
956 1048
         switch (strtoupper($dest)) {
957 1049
             case 'I':
958 1050
                 // Send to standard output
@@ -977,8 +1069,9 @@  discard block
 block discarded – undo
977 1069
                 break;
978 1070
             case 'F':
979 1071
                 // Save to local file
980
-                if (!file_put_contents($name, $this->buffer))
981
-                    $this->Error('Unable to create output file: ' . $name);
1072
+                if (!file_put_contents($name, $this->buffer)) {
1073
+                                    $this->Error('Unable to create output file: ' . $name);
1074
+                }
982 1075
                 break;
983 1076
             case 'S':
984 1077
                 // Return as a string
@@ -996,26 +1089,30 @@  discard block
 block discarded – undo
996 1089
     protected function _dochecks()
997 1090
     {
998 1091
         // Check mbstring overloading
999
-        if (ini_get('mbstring.func_overload') & 2)
1000
-            $this->Error('mbstring overloading must be disabled');
1092
+        if (ini_get('mbstring.func_overload') & 2) {
1093
+                    $this->Error('mbstring overloading must be disabled');
1094
+        }
1001 1095
         // Ensure runtime magic quotes are disabled
1002
-        if (get_magic_quotes_runtime())
1003
-            @set_magic_quotes_runtime(0);
1096
+        if (get_magic_quotes_runtime()) {
1097
+                    @set_magic_quotes_runtime(0);
1098
+        }
1004 1099
     }
1005 1100
 
1006 1101
     protected function _checkoutput()
1007 1102
     {
1008 1103
         if (PHP_SAPI != 'cli') {
1009
-            if (headers_sent($file, $line))
1010
-                $this->Error("Some data has already been output, can't send PDF file (output started at $file:$line)");
1104
+            if (headers_sent($file, $line)) {
1105
+                            $this->Error("Some data has already been output, can't send PDF file (output started at $file:$line)");
1106
+            }
1011 1107
         }
1012 1108
         if (ob_get_length()) {
1013 1109
             // The output buffer is not empty
1014 1110
             if (preg_match('/^(\xEF\xBB\xBF)?\s*$/', ob_get_contents())) {
1015 1111
                 // It contains only a UTF-8 BOM and/or whitespace, let's clean it
1016 1112
                 ob_clean();
1017
-            } else
1018
-                $this->Error("Some data has already been output, can't send PDF file");
1113
+            } else {
1114
+                            $this->Error("Some data has already been output, can't send PDF file");
1115
+            }
1019 1116
         }
1020 1117
     }
1021 1118
 
@@ -1023,15 +1120,17 @@  discard block
 block discarded – undo
1023 1120
     {
1024 1121
         if (is_string($size)) {
1025 1122
             $size = strtolower($size);
1026
-            if (!isset($this->StdPageSizes[$size]))
1027
-                $this->Error('Unknown page size: ' . $size);
1123
+            if (!isset($this->StdPageSizes[$size])) {
1124
+                            $this->Error('Unknown page size: ' . $size);
1125
+            }
1028 1126
             $a = $this->StdPageSizes[$size];
1029 1127
             return array($a[0] / $this->k, $a[1] / $this->k);
1030 1128
         } else {
1031
-            if ($size[0] > $size[1])
1032
-                return array($size[1], $size[0]);
1033
-            else
1034
-                return $size;
1129
+            if ($size[0] > $size[1]) {
1130
+                            return array($size[1], $size[0]);
1131
+            } else {
1132
+                            return $size;
1133
+            }
1035 1134
         }
1036 1135
     }
1037 1136
 
@@ -1044,14 +1143,16 @@  discard block
 block discarded – undo
1044 1143
         $this->y = $this->tMargin;
1045 1144
         $this->FontFamily = '';
1046 1145
         // Check page size and orientation
1047
-        if ($orientation == '')
1048
-            $orientation = $this->DefOrientation;
1049
-        else
1050
-            $orientation = strtoupper($orientation[0]);
1051
-        if ($size == '')
1052
-            $size = $this->DefPageSize;
1053
-        else
1054
-            $size = $this->_getpagesize($size);
1146
+        if ($orientation == '') {
1147
+                    $orientation = $this->DefOrientation;
1148
+        } else {
1149
+                    $orientation = strtoupper($orientation[0]);
1150
+        }
1151
+        if ($size == '') {
1152
+                    $size = $this->DefPageSize;
1153
+        } else {
1154
+                    $size = $this->_getpagesize($size);
1155
+        }
1055 1156
         if ($orientation != $this->CurOrientation || $size[0] != $this->CurPageSize[0] || $size[1] != $this->CurPageSize[1]) {
1056 1157
             // New size or orientation
1057 1158
             if ($orientation == 'P') {
@@ -1067,11 +1168,13 @@  discard block
 block discarded – undo
1067 1168
             $this->CurOrientation = $orientation;
1068 1169
             $this->CurPageSize = $size;
1069 1170
         }
1070
-        if ($orientation != $this->DefOrientation || $size[0] != $this->DefPageSize[0] || $size[1] != $this->DefPageSize[1])
1071
-            $this->PageInfo[$this->page]['size'] = array($this->wPt, $this->hPt);
1171
+        if ($orientation != $this->DefOrientation || $size[0] != $this->DefPageSize[0] || $size[1] != $this->DefPageSize[1]) {
1172
+                    $this->PageInfo[$this->page]['size'] = array($this->wPt, $this->hPt);
1173
+        }
1072 1174
         if ($rotation != 0) {
1073
-            if ($rotation % 90 != 0)
1074
-                $this->Error('Incorrect rotation value: ' . $rotation);
1175
+            if ($rotation % 90 != 0) {
1176
+                            $this->Error('Incorrect rotation value: ' . $rotation);
1177
+            }
1075 1178
             $this->CurRotation = $rotation;
1076 1179
             $this->PageInfo[$this->page]['rotation'] = $rotation;
1077 1180
         }
@@ -1085,15 +1188,19 @@  discard block
 block discarded – undo
1085 1188
     protected function _loadfont($font)
1086 1189
     {
1087 1190
         // Load a font definition file from the font directory
1088
-        if (strpos($font, '/') !== false || strpos($font, "\\") !== false)
1089
-            $this->Error('Incorrect font definition file name: ' . $font);
1191
+        if (strpos($font, '/') !== false || strpos($font, "\\") !== false) {
1192
+                    $this->Error('Incorrect font definition file name: ' . $font);
1193
+        }
1090 1194
         include($this->fontpath . $font);
1091
-        if (!isset($name))
1092
-            $this->Error('Could not include font definition file');
1093
-        if (isset($enc))
1094
-            $enc = strtolower($enc);
1095
-        if (!isset($subsetted))
1096
-            $subsetted = false;
1195
+        if (!isset($name)) {
1196
+                    $this->Error('Could not include font definition file');
1197
+        }
1198
+        if (isset($enc)) {
1199
+                    $enc = strtolower($enc);
1200
+        }
1201
+        if (!isset($subsetted)) {
1202
+                    $subsetted = false;
1203
+        }
1097 1204
         return get_defined_vars();
1098 1205
     }
1099 1206
 
@@ -1102,8 +1209,9 @@  discard block
 block discarded – undo
1102 1209
         // Test if string is ASCII
1103 1210
         $nb = strlen($s);
1104 1211
         for ($i = 0; $i < $nb; $i++) {
1105
-            if (ord($s[$i]) > 127)
1106
-                return false;
1212
+            if (ord($s[$i]) > 127) {
1213
+                            return false;
1214
+            }
1107 1215
         }
1108 1216
         return true;
1109 1217
     }
@@ -1111,14 +1219,17 @@  discard block
 block discarded – undo
1111 1219
     protected function _httpencode($param, $value, $isUTF8)
1112 1220
     {
1113 1221
         // Encode HTTP header field parameter
1114
-        if ($this->_isascii($value))
1115
-            return $param . '="' . $value . '"';
1116
-        if (!$isUTF8)
1117
-            $value = utf8_encode($value);
1118
-        if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false)
1119
-            return $param . '="' . rawurlencode($value) . '"';
1120
-        else
1121
-            return $param . "*=UTF-8''" . rawurlencode($value);
1222
+        if ($this->_isascii($value)) {
1223
+                    return $param . '="' . $value . '"';
1224
+        }
1225
+        if (!$isUTF8) {
1226
+                    $value = utf8_encode($value);
1227
+        }
1228
+        if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false) {
1229
+                    return $param . '="' . rawurlencode($value) . '"';
1230
+        } else {
1231
+                    return $param . "*=UTF-8''" . rawurlencode($value);
1232
+        }
1122 1233
     }
1123 1234
 
1124 1235
     protected function _UTF8toUTF16($s)
@@ -1151,17 +1262,19 @@  discard block
 block discarded – undo
1151 1262
     protected function _escape($s)
1152 1263
     {
1153 1264
         // Escape special characters
1154
-        if (strpos($s, '(') !== false || strpos($s, ')') !== false || strpos($s, '\\') !== false || strpos($s, "\r") !== false)
1155
-            return str_replace(array('\\', '(', ')', "\r"), array('\\\\', '\\(', '\\)', '\\r'), $s);
1156
-        else
1157
-            return $s;
1265
+        if (strpos($s, '(') !== false || strpos($s, ')') !== false || strpos($s, '\\') !== false || strpos($s, "\r") !== false) {
1266
+                    return str_replace(array('\\', '(', ')', "\r"), array('\\\\', '\\(', '\\)', '\\r'), $s);
1267
+        } else {
1268
+                    return $s;
1269
+        }
1158 1270
     }
1159 1271
 
1160 1272
     protected function _textstring($s)
1161 1273
     {
1162 1274
         // Format a text string
1163
-        if (!$this->_isascii($s))
1164
-            $s = $this->_UTF8toUTF16($s);
1275
+        if (!$this->_isascii($s)) {
1276
+                    $s = $this->_UTF8toUTF16($s);
1277
+        }
1165 1278
         return '(' . $this->_escape($s) . ')';
1166 1279
     }
1167 1280
 
@@ -1178,16 +1291,19 @@  discard block
 block discarded – undo
1178 1291
     {
1179 1292
         // Extract info from a JPEG file
1180 1293
         $a = getimagesize($file);
1181
-        if (!$a)
1182
-            $this->Error('Missing or incorrect image file: ' . $file);
1183
-        if ($a[2] != 2)
1184
-            $this->Error('Not a JPEG file: ' . $file);
1185
-        if (!isset($a['channels']) || $a['channels'] == 3)
1186
-            $colspace = 'DeviceRGB';
1187
-        elseif ($a['channels'] == 4)
1188
-            $colspace = 'DeviceCMYK';
1189
-        else
1190
-            $colspace = 'DeviceGray';
1294
+        if (!$a) {
1295
+                    $this->Error('Missing or incorrect image file: ' . $file);
1296
+        }
1297
+        if ($a[2] != 2) {
1298
+                    $this->Error('Not a JPEG file: ' . $file);
1299
+        }
1300
+        if (!isset($a['channels']) || $a['channels'] == 3) {
1301
+                    $colspace = 'DeviceRGB';
1302
+        } elseif ($a['channels'] == 4) {
1303
+                    $colspace = 'DeviceCMYK';
1304
+        } else {
1305
+                    $colspace = 'DeviceGray';
1306
+        }
1191 1307
         $bpc = isset($a['bits']) ? $a['bits'] : 8;
1192 1308
         $data = file_get_contents($file);
1193 1309
         return array('w' => $a[0], 'h' => $a[1], 'cs' => $colspace, 'bpc' => $bpc, 'f' => 'DCTDecode', 'data' => $data);
@@ -1197,8 +1313,9 @@  discard block
 block discarded – undo
1197 1313
     {
1198 1314
         // Extract info from a PNG file
1199 1315
         $f = fopen($file, 'rb');
1200
-        if (!$f)
1201
-            $this->Error('Can\'t open image file: ' . $file);
1316
+        if (!$f) {
1317
+                    $this->Error('Can\'t open image file: ' . $file);
1318
+        }
1202 1319
         $info = $this->_parsepngstream($f, $file);
1203 1320
         fclose($f);
1204 1321
         return $info;
@@ -1207,33 +1324,40 @@  discard block
 block discarded – undo
1207 1324
     protected function _parsepngstream($f, $file)
1208 1325
     {
1209 1326
         // Check signature
1210
-        if ($this->_readstream($f, 8) != chr(137) . 'PNG' . chr(13) . chr(10) . chr(26) . chr(10))
1211
-            $this->Error('Not a PNG file: ' . $file);
1327
+        if ($this->_readstream($f, 8) != chr(137) . 'PNG' . chr(13) . chr(10) . chr(26) . chr(10)) {
1328
+                    $this->Error('Not a PNG file: ' . $file);
1329
+        }
1212 1330
 
1213 1331
         // Read header chunk
1214 1332
         $this->_readstream($f, 4);
1215
-        if ($this->_readstream($f, 4) != 'IHDR')
1216
-            $this->Error('Incorrect PNG file: ' . $file);
1333
+        if ($this->_readstream($f, 4) != 'IHDR') {
1334
+                    $this->Error('Incorrect PNG file: ' . $file);
1335
+        }
1217 1336
         $w = $this->_readint($f);
1218 1337
         $h = $this->_readint($f);
1219 1338
         $bpc = ord($this->_readstream($f, 1));
1220
-        if ($bpc > 8)
1221
-            $this->Error('16-bit depth not supported: ' . $file);
1339
+        if ($bpc > 8) {
1340
+                    $this->Error('16-bit depth not supported: ' . $file);
1341
+        }
1222 1342
         $ct = ord($this->_readstream($f, 1));
1223
-        if ($ct == 0 || $ct == 4)
1224
-            $colspace = 'DeviceGray';
1225
-        elseif ($ct == 2 || $ct == 6)
1226
-            $colspace = 'DeviceRGB';
1227
-        elseif ($ct == 3)
1228
-            $colspace = 'Indexed';
1229
-        else
1230
-            $this->Error('Unknown color type: ' . $file);
1231
-        if (ord($this->_readstream($f, 1)) != 0)
1232
-            $this->Error('Unknown compression method: ' . $file);
1233
-        if (ord($this->_readstream($f, 1)) != 0)
1234
-            $this->Error('Unknown filter method: ' . $file);
1235
-        if (ord($this->_readstream($f, 1)) != 0)
1236
-            $this->Error('Interlacing not supported: ' . $file);
1343
+        if ($ct == 0 || $ct == 4) {
1344
+                    $colspace = 'DeviceGray';
1345
+        } elseif ($ct == 2 || $ct == 6) {
1346
+                    $colspace = 'DeviceRGB';
1347
+        } elseif ($ct == 3) {
1348
+                    $colspace = 'Indexed';
1349
+        } else {
1350
+                    $this->Error('Unknown color type: ' . $file);
1351
+        }
1352
+        if (ord($this->_readstream($f, 1)) != 0) {
1353
+                    $this->Error('Unknown compression method: ' . $file);
1354
+        }
1355
+        if (ord($this->_readstream($f, 1)) != 0) {
1356
+                    $this->Error('Unknown filter method: ' . $file);
1357
+        }
1358
+        if (ord($this->_readstream($f, 1)) != 0) {
1359
+                    $this->Error('Interlacing not supported: ' . $file);
1360
+        }
1237 1361
         $this->_readstream($f, 4);
1238 1362
         $dp = '/Predictor 15 /Colors ' . ($colspace == 'DeviceRGB' ? 3 : 1) . ' /BitsPerComponent ' . $bpc . ' /Columns ' . $w;
1239 1363
 
@@ -1251,33 +1375,37 @@  discard block
 block discarded – undo
1251 1375
             } elseif ($type == 'tRNS') {
1252 1376
                 // Read transparency info
1253 1377
                 $t = $this->_readstream($f, $n);
1254
-                if ($ct == 0)
1255
-                    $trns = array(ord(substr($t, 1, 1)));
1256
-                elseif ($ct == 2)
1257
-                    $trns = array(ord(substr($t, 1, 1)), ord(substr($t, 3, 1)), ord(substr($t, 5, 1)));
1258
-                else {
1378
+                if ($ct == 0) {
1379
+                                    $trns = array(ord(substr($t, 1, 1)));
1380
+                } elseif ($ct == 2) {
1381
+                                    $trns = array(ord(substr($t, 1, 1)), ord(substr($t, 3, 1)), ord(substr($t, 5, 1)));
1382
+                } else {
1259 1383
                     $pos = strpos($t, chr(0));
1260
-                    if ($pos !== false)
1261
-                        $trns = array($pos);
1384
+                    if ($pos !== false) {
1385
+                                            $trns = array($pos);
1386
+                    }
1262 1387
                 }
1263 1388
                 $this->_readstream($f, 4);
1264 1389
             } elseif ($type == 'IDAT') {
1265 1390
                 // Read image data block
1266 1391
                 $data .= $this->_readstream($f, $n);
1267 1392
                 $this->_readstream($f, 4);
1268
-            } elseif ($type == 'IEND')
1269
-                break;
1270
-            else
1271
-                $this->_readstream($f, $n + 4);
1393
+            } elseif ($type == 'IEND') {
1394
+                            break;
1395
+            } else {
1396
+                            $this->_readstream($f, $n + 4);
1397
+            }
1272 1398
         } while ($n);
1273 1399
 
1274
-        if ($colspace == 'Indexed' && empty($pal))
1275
-            $this->Error('Missing palette in ' . $file);
1400
+        if ($colspace == 'Indexed' && empty($pal)) {
1401
+                    $this->Error('Missing palette in ' . $file);
1402
+        }
1276 1403
         $info = array('w' => $w, 'h' => $h, 'cs' => $colspace, 'bpc' => $bpc, 'f' => 'FlateDecode', 'dp' => $dp, 'pal' => $pal, 'trns' => $trns);
1277 1404
         if ($ct >= 4) {
1278 1405
             // Extract alpha channel
1279
-            if (!function_exists('gzuncompress'))
1280
-                $this->Error('Zlib not available, can\'t handle alpha channel: ' . $file);
1406
+            if (!function_exists('gzuncompress')) {
1407
+                            $this->Error('Zlib not available, can\'t handle alpha channel: ' . $file);
1408
+            }
1281 1409
             $data = gzuncompress($data);
1282 1410
             $color = '';
1283 1411
             $alpha = '';
@@ -1308,8 +1436,9 @@  discard block
 block discarded – undo
1308 1436
             $data = gzcompress($color);
1309 1437
             $info['smask'] = gzcompress($alpha);
1310 1438
             $this->WithAlpha = true;
1311
-            if ($this->PDFVersion < '1.4')
1312
-                $this->PDFVersion = '1.4';
1439
+            if ($this->PDFVersion < '1.4') {
1440
+                            $this->PDFVersion = '1.4';
1441
+            }
1313 1442
         }
1314 1443
         $info['data'] = $data;
1315 1444
         return $info;
@@ -1321,13 +1450,15 @@  discard block
 block discarded – undo
1321 1450
         $res = '';
1322 1451
         while ($n > 0 && !feof($f)) {
1323 1452
             $s = fread($f, $n);
1324
-            if ($s === false)
1325
-                $this->Error('Error while reading stream');
1453
+            if ($s === false) {
1454
+                            $this->Error('Error while reading stream');
1455
+            }
1326 1456
             $n -= strlen($s);
1327 1457
             $res .= $s;
1328 1458
         }
1329
-        if ($n > 0)
1330
-            $this->Error('Unexpected end of stream');
1459
+        if ($n > 0) {
1460
+                    $this->Error('Unexpected end of stream');
1461
+        }
1331 1462
         return $res;
1332 1463
     }
1333 1464
 
@@ -1341,21 +1472,25 @@  discard block
 block discarded – undo
1341 1472
     protected function _parsegif($file)
1342 1473
     {
1343 1474
         // Extract info from a GIF file (via PNG conversion)
1344
-        if (!function_exists('imagepng'))
1345
-            $this->Error('GD extension is required for GIF support');
1346
-        if (!function_exists('imagecreatefromgif'))
1347
-            $this->Error('GD has no GIF read support');
1475
+        if (!function_exists('imagepng')) {
1476
+                    $this->Error('GD extension is required for GIF support');
1477
+        }
1478
+        if (!function_exists('imagecreatefromgif')) {
1479
+                    $this->Error('GD has no GIF read support');
1480
+        }
1348 1481
         $im = imagecreatefromgif($file);
1349
-        if (!$im)
1350
-            $this->Error('Missing or incorrect image file: ' . $file);
1482
+        if (!$im) {
1483
+                    $this->Error('Missing or incorrect image file: ' . $file);
1484
+        }
1351 1485
         imageinterlace($im, 0);
1352 1486
         ob_start();
1353 1487
         imagepng($im);
1354 1488
         $data = ob_get_clean();
1355 1489
         imagedestroy($im);
1356 1490
         $f = fopen('php://temp', 'rb+');
1357
-        if (!$f)
1358
-            $this->Error('Unable to create memory stream');
1491
+        if (!$f) {
1492
+                    $this->Error('Unable to create memory stream');
1493
+        }
1359 1494
         fwrite($f, $data);
1360 1495
         rewind($f);
1361 1496
         $info = $this->_parsepngstream($f, $file);
@@ -1366,14 +1501,15 @@  discard block
 block discarded – undo
1366 1501
     protected function _out($s)
1367 1502
     {
1368 1503
         // Add a line to the document
1369
-        if ($this->state == 2)
1370
-            $this->pages[$this->page] .= $s . "\n";
1371
-        elseif ($this->state == 1)
1372
-            $this->_put($s);
1373
-        elseif ($this->state == 0)
1374
-            $this->Error('No page has been added yet');
1375
-        elseif ($this->state == 3)
1376
-            $this->Error('The document is closed');
1504
+        if ($this->state == 2) {
1505
+                    $this->pages[$this->page] .= $s . "\n";
1506
+        } elseif ($this->state == 1) {
1507
+                    $this->_put($s);
1508
+        } elseif ($this->state == 0) {
1509
+                    $this->Error('No page has been added yet');
1510
+        } elseif ($this->state == 3) {
1511
+                    $this->Error('The document is closed');
1512
+        }
1377 1513
     }
1378 1514
 
1379 1515
     protected function _put($s)
@@ -1389,8 +1525,9 @@  discard block
 block discarded – undo
1389 1525
     protected function _newobj($n = null)
1390 1526
     {
1391 1527
         // Begin a new object
1392
-        if ($n === null)
1393
-            $n = ++$this->n;
1528
+        if ($n === null) {
1529
+                    $n = ++$this->n;
1530
+        }
1394 1531
         $this->offsets[$n] = $this->_getoffset();
1395 1532
         $this->_put($n . ' 0 obj');
1396 1533
     }
@@ -1407,8 +1544,9 @@  discard block
 block discarded – undo
1407 1544
         if ($this->compress) {
1408 1545
             $entries = '/Filter /FlateDecode ';
1409 1546
             $data = gzcompress($data);
1410
-        } else
1411
-            $entries = '';
1547
+        } else {
1548
+                    $entries = '';
1549
+        }
1412 1550
         $entries .= '/Length ' . strlen($data);
1413 1551
         $this->_newobj();
1414 1552
         $this->_put('<<' . $entries . '>>');
@@ -1421,10 +1559,12 @@  discard block
 block discarded – undo
1421 1559
         $this->_newobj();
1422 1560
         $this->_put('<</Type /Page');
1423 1561
         $this->_put('/Parent 1 0 R');
1424
-        if (isset($this->PageInfo[$n]['size']))
1425
-            $this->_put(sprintf('/MediaBox [0 0 %.2F %.2F]', $this->PageInfo[$n]['size'][0], $this->PageInfo[$n]['size'][1]));
1426
-        if (isset($this->PageInfo[$n]['rotation']))
1427
-            $this->_put('/Rotate ' . $this->PageInfo[$n]['rotation']);
1562
+        if (isset($this->PageInfo[$n]['size'])) {
1563
+                    $this->_put(sprintf('/MediaBox [0 0 %.2F %.2F]', $this->PageInfo[$n]['size'][0], $this->PageInfo[$n]['size'][1]));
1564
+        }
1565
+        if (isset($this->PageInfo[$n]['rotation'])) {
1566
+                    $this->_put('/Rotate ' . $this->PageInfo[$n]['rotation']);
1567
+        }
1428 1568
         $this->_put('/Resources 2 0 R');
1429 1569
         if (isset($this->PageLinks[$n])) {
1430 1570
             // Links
@@ -1432,42 +1572,48 @@  discard block
 block discarded – undo
1432 1572
             foreach ($this->PageLinks[$n] as $pl) {
1433 1573
                 $rect = sprintf('%.2F %.2F %.2F %.2F', $pl[0], $pl[1], $pl[0] + $pl[2], $pl[1] - $pl[3]);
1434 1574
                 $annots .= '<</Type /Annot /Subtype /Link /Rect [' . $rect . '] /Border [0 0 0] ';
1435
-                if (is_string($pl[4]))
1436
-                    $annots .= '/A <</S /URI /URI ' . $this->_textstring($pl[4]) . '>>>>';
1437
-                else {
1575
+                if (is_string($pl[4])) {
1576
+                                    $annots .= '/A <</S /URI /URI ' . $this->_textstring($pl[4]) . '>>>>';
1577
+                } else {
1438 1578
                     $l = $this->links[$pl[4]];
1439
-                    if (isset($this->PageInfo[$l[0]]['size']))
1440
-                        $h = $this->PageInfo[$l[0]]['size'][1];
1441
-                    else
1442
-                        $h = ($this->DefOrientation == 'P') ? $this->DefPageSize[1] * $this->k : $this->DefPageSize[0] * $this->k;
1579
+                    if (isset($this->PageInfo[$l[0]]['size'])) {
1580
+                                            $h = $this->PageInfo[$l[0]]['size'][1];
1581
+                    } else {
1582
+                                            $h = ($this->DefOrientation == 'P') ? $this->DefPageSize[1] * $this->k : $this->DefPageSize[0] * $this->k;
1583
+                    }
1443 1584
                     $annots .= sprintf('/Dest [%d 0 R /XYZ 0 %.2F null]>>', $this->PageInfo[$l[0]]['n'], $h - $l[1] * $this->k);
1444 1585
                 }
1445 1586
             }
1446 1587
             $this->_put($annots . ']');
1447 1588
         }
1448
-        if ($this->WithAlpha)
1449
-            $this->_put('/Group <</Type /Group /S /Transparency /CS /DeviceRGB>>');
1589
+        if ($this->WithAlpha) {
1590
+                    $this->_put('/Group <</Type /Group /S /Transparency /CS /DeviceRGB>>');
1591
+        }
1450 1592
         $this->_put('/Contents ' . ($this->n + 1) . ' 0 R>>');
1451 1593
         $this->_put('endobj');
1452 1594
         // Page content
1453
-        if (!empty($this->AliasNbPages))
1454
-            $this->pages[$n] = str_replace($this->AliasNbPages, $this->page, $this->pages[$n]);
1595
+        if (!empty($this->AliasNbPages)) {
1596
+                    $this->pages[$n] = str_replace($this->AliasNbPages, $this->page, $this->pages[$n]);
1597
+        }
1455 1598
         $this->_putstreamobject($this->pages[$n]);
1456 1599
     }
1457 1600
 
1458 1601
     protected function _putpages()
1459 1602
     {
1460 1603
         $nb = $this->page;
1461
-        for ($n = 1; $n <= $nb; $n++)
1462
-            $this->PageInfo[$n]['n'] = $this->n + 1 + 2 * ($n - 1);
1463
-        for ($n = 1; $n <= $nb; $n++)
1464
-            $this->_putpage($n);
1604
+        for ($n = 1; $n <= $nb; $n++) {
1605
+                    $this->PageInfo[$n]['n'] = $this->n + 1 + 2 * ($n - 1);
1606
+        }
1607
+        for ($n = 1; $n <= $nb; $n++) {
1608
+                    $this->_putpage($n);
1609
+        }
1465 1610
         // Pages root
1466 1611
         $this->_newobj(1);
1467 1612
         $this->_put('<</Type /Pages');
1468 1613
         $kids = '/Kids [';
1469
-        for ($n = 1; $n <= $nb; $n++)
1470
-            $kids .= $this->PageInfo[$n]['n'] . ' 0 R ';
1614
+        for ($n = 1; $n <= $nb; $n++) {
1615
+                    $kids .= $this->PageInfo[$n]['n'] . ' 0 R ';
1616
+        }
1471 1617
         $this->_put($kids . ']');
1472 1618
         $this->_put('/Count ' . $nb);
1473 1619
         if ($this->DefOrientation == 'P') {
@@ -1489,17 +1635,21 @@  discard block
 block discarded – undo
1489 1635
             $this->_newobj();
1490 1636
             $this->FontFiles[$file]['n'] = $this->n;
1491 1637
             $font = file_get_contents($this->fontpath . $file, true);
1492
-            if (!$font)
1493
-                $this->Error('Font file not found: ' . $file);
1638
+            if (!$font) {
1639
+                            $this->Error('Font file not found: ' . $file);
1640
+            }
1494 1641
             $compressed = (substr($file, -2) == '.z');
1495
-            if (!$compressed && isset($info['length2']))
1496
-                $font = substr($font, 6, $info['length1']) . substr($font, 6 + $info['length1'] + 6, $info['length2']);
1642
+            if (!$compressed && isset($info['length2'])) {
1643
+                            $font = substr($font, 6, $info['length1']) . substr($font, 6 + $info['length1'] + 6, $info['length2']);
1644
+            }
1497 1645
             $this->_put('<</Length ' . strlen($font));
1498
-            if ($compressed)
1499
-                $this->_put('/Filter /FlateDecode');
1646
+            if ($compressed) {
1647
+                            $this->_put('/Filter /FlateDecode');
1648
+            }
1500 1649
             $this->_put('/Length1 ' . $info['length1']);
1501
-            if (isset($info['length2']))
1502
-                $this->_put('/Length2 ' . $info['length2'] . ' /Length3 0');
1650
+            if (isset($info['length2'])) {
1651
+                            $this->_put('/Length2 ' . $info['length2'] . ' /Length3 0');
1652
+            }
1503 1653
             $this->_put('>>');
1504 1654
             $this->_putstream($font);
1505 1655
             $this->_put('endobj');
@@ -1516,10 +1666,11 @@  discard block
 block discarded – undo
1516 1666
             }
1517 1667
             // ToUnicode CMap
1518 1668
             if (isset($font['uv'])) {
1519
-                if (isset($font['enc']))
1520
-                    $cmapkey = $font['enc'];
1521
-                else
1522
-                    $cmapkey = $font['name'];
1669
+                if (isset($font['enc'])) {
1670
+                                    $cmapkey = $font['enc'];
1671
+                } else {
1672
+                                    $cmapkey = $font['name'];
1673
+                }
1523 1674
                 if (!isset($this->cmaps[$cmapkey])) {
1524 1675
                     $cmap = $this->_tounicodecmap($font['uv']);
1525 1676
                     $this->_putstreamobject($cmap);
@@ -1530,18 +1681,21 @@  discard block
 block discarded – undo
1530 1681
             $this->fonts[$k]['n'] = $this->n + 1;
1531 1682
             $type = $font['type'];
1532 1683
             $name = $font['name'];
1533
-            if ($font['subsetted'])
1534
-                $name = 'AAAAAA+' . $name;
1684
+            if ($font['subsetted']) {
1685
+                            $name = 'AAAAAA+' . $name;
1686
+            }
1535 1687
             if ($type == 'Core') {
1536 1688
                 // Core font
1537 1689
                 $this->_newobj();
1538 1690
                 $this->_put('<</Type /Font');
1539 1691
                 $this->_put('/BaseFont /' . $name);
1540 1692
                 $this->_put('/Subtype /Type1');
1541
-                if ($name != 'Symbol' && $name != 'ZapfDingbats')
1542
-                    $this->_put('/Encoding /WinAnsiEncoding');
1543
-                if (isset($font['uv']))
1544
-                    $this->_put('/ToUnicode ' . $this->cmaps[$cmapkey] . ' 0 R');
1693
+                if ($name != 'Symbol' && $name != 'ZapfDingbats') {
1694
+                                    $this->_put('/Encoding /WinAnsiEncoding');
1695
+                }
1696
+                if (isset($font['uv'])) {
1697
+                                    $this->_put('/ToUnicode ' . $this->cmaps[$cmapkey] . ' 0 R');
1698
+                }
1545 1699
                 $this->_put('>>');
1546 1700
                 $this->_put('endobj');
1547 1701
             } elseif ($type == 'Type1' || $type == 'TrueType') {
@@ -1553,36 +1707,42 @@  discard block
 block discarded – undo
1553 1707
                 $this->_put('/FirstChar 32 /LastChar 255');
1554 1708
                 $this->_put('/Widths ' . ($this->n + 1) . ' 0 R');
1555 1709
                 $this->_put('/FontDescriptor ' . ($this->n + 2) . ' 0 R');
1556
-                if (isset($font['diff']))
1557
-                    $this->_put('/Encoding ' . $this->encodings[$font['enc']] . ' 0 R');
1558
-                else
1559
-                    $this->_put('/Encoding /WinAnsiEncoding');
1560
-                if (isset($font['uv']))
1561
-                    $this->_put('/ToUnicode ' . $this->cmaps[$cmapkey] . ' 0 R');
1710
+                if (isset($font['diff'])) {
1711
+                                    $this->_put('/Encoding ' . $this->encodings[$font['enc']] . ' 0 R');
1712
+                } else {
1713
+                                    $this->_put('/Encoding /WinAnsiEncoding');
1714
+                }
1715
+                if (isset($font['uv'])) {
1716
+                                    $this->_put('/ToUnicode ' . $this->cmaps[$cmapkey] . ' 0 R');
1717
+                }
1562 1718
                 $this->_put('>>');
1563 1719
                 $this->_put('endobj');
1564 1720
                 // Widths
1565 1721
                 $this->_newobj();
1566 1722
                 $cw = &$font['cw'];
1567 1723
                 $s = '[';
1568
-                for ($i = 32; $i <= 255; $i++)
1569
-                    $s .= $cw[chr($i)] . ' ';
1724
+                for ($i = 32; $i <= 255; $i++) {
1725
+                                    $s .= $cw[chr($i)] . ' ';
1726
+                }
1570 1727
                 $this->_put($s . ']');
1571 1728
                 $this->_put('endobj');
1572 1729
                 // Descriptor
1573 1730
                 $this->_newobj();
1574 1731
                 $s = '<</Type /FontDescriptor /FontName /' . $name;
1575
-                foreach ($font['desc'] as $k => $v)
1576
-                    $s .= ' /' . $k . ' ' . $v;
1577
-                if (!empty($font['file']))
1578
-                    $s .= ' /FontFile' . ($type == 'Type1' ? '' : '2') . ' ' . $this->FontFiles[$font['file']]['n'] . ' 0 R';
1732
+                foreach ($font['desc'] as $k => $v) {
1733
+                                    $s .= ' /' . $k . ' ' . $v;
1734
+                }
1735
+                if (!empty($font['file'])) {
1736
+                                    $s .= ' /FontFile' . ($type == 'Type1' ? '' : '2') . ' ' . $this->FontFiles[$font['file']]['n'] . ' 0 R';
1737
+                }
1579 1738
                 $this->_put($s . '>>');
1580 1739
                 $this->_put('endobj');
1581 1740
             } else {
1582 1741
                 // Allow for additional types
1583 1742
                 $mtd = '_put' . strtolower($type);
1584
-                if (!method_exists($this, $mtd))
1585
-                    $this->Error('Unsupported font type: ' . $type);
1743
+                if (!method_exists($this, $mtd)) {
1744
+                                    $this->Error('Unsupported font type: ' . $type);
1745
+                }
1586 1746
                 $this->$mtd($font);
1587 1747
             }
1588 1748
         }
@@ -1650,26 +1810,31 @@  discard block
 block discarded – undo
1650 1810
         $this->_put('/Subtype /Image');
1651 1811
         $this->_put('/Width ' . $info['w']);
1652 1812
         $this->_put('/Height ' . $info['h']);
1653
-        if ($info['cs'] == 'Indexed')
1654
-            $this->_put('/ColorSpace [/Indexed /DeviceRGB ' . (strlen($info['pal']) / 3 - 1) . ' ' . ($this->n + 1) . ' 0 R]');
1655
-        else {
1813
+        if ($info['cs'] == 'Indexed') {
1814
+                    $this->_put('/ColorSpace [/Indexed /DeviceRGB ' . (strlen($info['pal']) / 3 - 1) . ' ' . ($this->n + 1) . ' 0 R]');
1815
+        } else {
1656 1816
             $this->_put('/ColorSpace /' . $info['cs']);
1657
-            if ($info['cs'] == 'DeviceCMYK')
1658
-                $this->_put('/Decode [1 0 1 0 1 0 1 0]');
1817
+            if ($info['cs'] == 'DeviceCMYK') {
1818
+                            $this->_put('/Decode [1 0 1 0 1 0 1 0]');
1819
+            }
1659 1820
         }
1660 1821
         $this->_put('/BitsPerComponent ' . $info['bpc']);
1661
-        if (isset($info['f']))
1662
-            $this->_put('/Filter /' . $info['f']);
1663
-        if (isset($info['dp']))
1664
-            $this->_put('/DecodeParms <<' . $info['dp'] . '>>');
1822
+        if (isset($info['f'])) {
1823
+                    $this->_put('/Filter /' . $info['f']);
1824
+        }
1825
+        if (isset($info['dp'])) {
1826
+                    $this->_put('/DecodeParms <<' . $info['dp'] . '>>');
1827
+        }
1665 1828
         if (isset($info['trns']) && is_array($info['trns'])) {
1666 1829
             $trns = '';
1667
-            for ($i = 0; $i < count($info['trns']); $i++)
1668
-                $trns .= $info['trns'][$i] . ' ' . $info['trns'][$i] . ' ';
1830
+            for ($i = 0; $i < count($info['trns']); $i++) {
1831
+                            $trns .= $info['trns'][$i] . ' ' . $info['trns'][$i] . ' ';
1832
+            }
1669 1833
             $this->_put('/Mask [' . $trns . ']');
1670 1834
         }
1671
-        if (isset($info['smask']))
1672
-            $this->_put('/SMask ' . ($this->n + 1) . ' 0 R');
1835
+        if (isset($info['smask'])) {
1836
+                    $this->_put('/SMask ' . ($this->n + 1) . ' 0 R');
1837
+        }
1673 1838
         $this->_put('/Length ' . strlen($info['data']) . '>>');
1674 1839
         $this->_putstream($info['data']);
1675 1840
         $this->_put('endobj');
@@ -1680,22 +1845,25 @@  discard block
 block discarded – undo
1680 1845
             $this->_putimage($smask);
1681 1846
         }
1682 1847
         // Palette
1683
-        if ($info['cs'] == 'Indexed')
1684
-            $this->_putstreamobject($info['pal']);
1848
+        if ($info['cs'] == 'Indexed') {
1849
+                    $this->_putstreamobject($info['pal']);
1850
+        }
1685 1851
     }
1686 1852
 
1687 1853
     protected function _putxobjectdict()
1688 1854
     {
1689
-        foreach ($this->images as $image)
1690
-            $this->_put('/I' . $image['i'] . ' ' . $image['n'] . ' 0 R');
1855
+        foreach ($this->images as $image) {
1856
+                    $this->_put('/I' . $image['i'] . ' ' . $image['n'] . ' 0 R');
1857
+        }
1691 1858
     }
1692 1859
 
1693 1860
     protected function _putresourcedict()
1694 1861
     {
1695 1862
         $this->_put('/ProcSet [/PDF /Text /ImageB /ImageC /ImageI]');
1696 1863
         $this->_put('/Font <<');
1697
-        foreach ($this->fonts as $font)
1698
-            $this->_put('/F' . $font['i'] . ' ' . $font['n'] . ' 0 R');
1864
+        foreach ($this->fonts as $font) {
1865
+                    $this->_put('/F' . $font['i'] . ' ' . $font['n'] . ' 0 R');
1866
+        }
1699 1867
         $this->_put('>>');
1700 1868
         $this->_put('/XObject <<');
1701 1869
         $this->_putxobjectdict();
@@ -1718,8 +1886,9 @@  discard block
 block discarded – undo
1718 1886
     {
1719 1887
         $this->metadata['Producer'] = 'FPDF ' . FPDF_VERSION;
1720 1888
         $this->metadata['CreationDate'] = 'D:' . @date('YmdHis');
1721
-        foreach ($this->metadata as $key => $value)
1722
-            $this->_put('/' . $key . ' ' . $this->_textstring($value));
1889
+        foreach ($this->metadata as $key => $value) {
1890
+                    $this->_put('/' . $key . ' ' . $this->_textstring($value));
1891
+        }
1723 1892
     }
1724 1893
 
1725 1894
     protected function _putcatalog()
@@ -1727,20 +1896,22 @@  discard block
 block discarded – undo
1727 1896
         $n = $this->PageInfo[1]['n'];
1728 1897
         $this->_put('/Type /Catalog');
1729 1898
         $this->_put('/Pages 1 0 R');
1730
-        if ($this->ZoomMode == 'fullpage')
1731
-            $this->_put('/OpenAction [' . $n . ' 0 R /Fit]');
1732
-        elseif ($this->ZoomMode == 'fullwidth')
1733
-            $this->_put('/OpenAction [' . $n . ' 0 R /FitH null]');
1734
-        elseif ($this->ZoomMode == 'real')
1735
-            $this->_put('/OpenAction [' . $n . ' 0 R /XYZ null null 1]');
1736
-        elseif (!is_string($this->ZoomMode))
1737
-            $this->_put('/OpenAction [' . $n . ' 0 R /XYZ null null ' . sprintf('%.2F', $this->ZoomMode / 100) . ']');
1738
-        if ($this->LayoutMode == 'single')
1739
-            $this->_put('/PageLayout /SinglePage');
1740
-        elseif ($this->LayoutMode == 'continuous')
1741
-            $this->_put('/PageLayout /OneColumn');
1742
-        elseif ($this->LayoutMode == 'two')
1743
-            $this->_put('/PageLayout /TwoColumnLeft');
1899
+        if ($this->ZoomMode == 'fullpage') {
1900
+                    $this->_put('/OpenAction [' . $n . ' 0 R /Fit]');
1901
+        } elseif ($this->ZoomMode == 'fullwidth') {
1902
+                    $this->_put('/OpenAction [' . $n . ' 0 R /FitH null]');
1903
+        } elseif ($this->ZoomMode == 'real') {
1904
+                    $this->_put('/OpenAction [' . $n . ' 0 R /XYZ null null 1]');
1905
+        } elseif (!is_string($this->ZoomMode)) {
1906
+                    $this->_put('/OpenAction [' . $n . ' 0 R /XYZ null null ' . sprintf('%.2F', $this->ZoomMode / 100) . ']');
1907
+        }
1908
+        if ($this->LayoutMode == 'single') {
1909
+                    $this->_put('/PageLayout /SinglePage');
1910
+        } elseif ($this->LayoutMode == 'continuous') {
1911
+                    $this->_put('/PageLayout /OneColumn');
1912
+        } elseif ($this->LayoutMode == 'two') {
1913
+                    $this->_put('/PageLayout /TwoColumnLeft');
1914
+        }
1744 1915
     }
1745 1916
 
1746 1917
     protected function _putheader()
@@ -1777,8 +1948,9 @@  discard block
 block discarded – undo
1777 1948
         $this->_put('xref');
1778 1949
         $this->_put('0 ' . ($this->n + 1));
1779 1950
         $this->_put('0000000000 65535 f ');
1780
-        for ($i = 1; $i <= $this->n; $i++)
1781
-            $this->_put(sprintf('%010d 00000 n ', $this->offsets[$i]));
1951
+        for ($i = 1; $i <= $this->n; $i++) {
1952
+                    $this->_put(sprintf('%010d 00000 n ', $this->offsets[$i]));
1953
+        }
1782 1954
         // Trailer
1783 1955
         $this->_put('trailer');
1784 1956
         $this->_put('<<');
Please login to merge, or discard this patch.
src/Ballybran/Library/fpdf/makefont/makefont.php 1 patch
Braces   +175 added lines, -134 removed lines patch added patch discarded remove patch
@@ -27,12 +27,14 @@  discard block
 block discarded – undo
27 27
 function Message($txt, $severity = '')
28 28
 {
29 29
     if (PHP_SAPI == 'cli') {
30
-        if ($severity)
31
-            echo "$severity: ";
30
+        if ($severity) {
31
+                    echo "$severity: ";
32
+        }
32 33
         echo "$txt\n";
33 34
     } else {
34
-        if ($severity)
35
-            echo "<b>$severity</b>: ";
35
+        if ($severity) {
36
+                    echo "<b>$severity</b>: ";
37
+        }
36 38
         echo "$txt<br>";
37 39
     }
38 40
 }
@@ -57,8 +59,9 @@  discard block
 block discarded – undo
57 59
 {
58 60
     $file = dirname(__FILE__) . '/' . strtolower($enc) . '.map';
59 61
     $a = file($file);
60
-    if (empty($a))
61
-        Error('Encoding not found: ' . $enc);
62
+    if (empty($a)) {
63
+            Error('Encoding not found: ' . $enc);
64
+    }
62 65
     $map = array_fill(0, 256, array('uv' => -1, 'name' => '.notdef'));
63 66
     foreach ($a as $line) {
64 67
         $e = explode(' ', rtrim($line));
@@ -80,18 +83,21 @@  discard block
 block discarded – undo
80 83
         Error($e->getMessage());
81 84
     }
82 85
     if ($embed) {
83
-        if (!$ttf->embeddable)
84
-            Error('Font license does not allow embedding');
86
+        if (!$ttf->embeddable) {
87
+                    Error('Font license does not allow embedding');
88
+        }
85 89
         if ($subset) {
86 90
             $chars = array();
87 91
             foreach ($map as $v) {
88
-                if ($v['name'] != '.notdef')
89
-                    $chars[] = $v['uv'];
92
+                if ($v['name'] != '.notdef') {
93
+                                    $chars[] = $v['uv'];
94
+                }
90 95
             }
91 96
             $ttf->Subset($chars);
92 97
             $info['Data'] = $ttf->Build();
93
-        } else
94
-            $info['Data'] = file_get_contents($file);
98
+        } else {
99
+                    $info['Data'] = file_get_contents($file);
100
+        }
95 101
         $info['OriginalSize'] = strlen($info['Data']);
96 102
     }
97 103
     $k = 1000 / $ttf->unitsPerEm;
@@ -113,8 +119,9 @@  discard block
 block discarded – undo
113 119
                 $id = $ttf->chars[$v['uv']];
114 120
                 $w = $ttf->glyphs[$id]['w'];
115 121
                 $widths[$c] = round($k * $w);
116
-            } else
117
-                Warning('Character ' . $v['name'] . ' is missing');
122
+            } else {
123
+                            Warning('Character ' . $v['name'] . ' is missing');
124
+            }
118 125
         }
119 126
     }
120 127
     $info['Widths'] = $widths;
@@ -126,18 +133,21 @@  discard block
 block discarded – undo
126 133
     // Return information from a Type1 font
127 134
     if ($embed) {
128 135
         $f = fopen($file, 'rb');
129
-        if (!$f)
130
-            Error('Can\'t open font file');
136
+        if (!$f) {
137
+                    Error('Can\'t open font file');
138
+        }
131 139
         // Read first segment
132 140
         $a = unpack('Cmarker/Ctype/Vsize', fread($f, 6));
133
-        if ($a['marker'] != 128)
134
-            Error('Font file is not a valid binary Type1');
141
+        if ($a['marker'] != 128) {
142
+                    Error('Font file is not a valid binary Type1');
143
+        }
135 144
         $size1 = $a['size'];
136 145
         $data = fread($f, $size1);
137 146
         // Read second segment
138 147
         $a = unpack('Cmarker/Ctype/Vsize', fread($f, 6));
139
-        if ($a['marker'] != 128)
140
-            Error('Font file is not a valid binary Type1');
148
+        if ($a['marker'] != 128) {
149
+                    Error('Font file is not a valid binary Type1');
150
+        }
141 151
         $size2 = $a['size'];
142 152
         $data .= fread($f, $size2);
143 153
         fclose($f);
@@ -147,62 +157,71 @@  discard block
 block discarded – undo
147 157
     }
148 158
 
149 159
     $afm = substr($file, 0, -3) . 'afm';
150
-    if (!file_exists($afm))
151
-        Error('AFM font file not found: ' . $afm);
160
+    if (!file_exists($afm)) {
161
+            Error('AFM font file not found: ' . $afm);
162
+    }
152 163
     $a = file($afm);
153
-    if (empty($a))
154
-        Error('AFM file empty or not readable');
164
+    if (empty($a)) {
165
+            Error('AFM file empty or not readable');
166
+    }
155 167
     foreach ($a as $line) {
156 168
         $e = explode(' ', rtrim($line));
157
-        if (count($e) < 2)
158
-            continue;
169
+        if (count($e) < 2) {
170
+                    continue;
171
+        }
159 172
         $entry = $e[0];
160 173
         if ($entry == 'C') {
161 174
             $w = $e[4];
162 175
             $name = $e[7];
163 176
             $cw[$name] = $w;
164
-        } elseif ($entry == 'FontName')
165
-            $info['FontName'] = $e[1];
166
-        elseif ($entry == 'Weight')
167
-            $info['Weight'] = $e[1];
168
-        elseif ($entry == 'ItalicAngle')
169
-            $info['ItalicAngle'] = (int)$e[1];
170
-        elseif ($entry == 'Ascender')
171
-            $info['Ascender'] = (int)$e[1];
172
-        elseif ($entry == 'Descender')
173
-            $info['Descender'] = (int)$e[1];
174
-        elseif ($entry == 'UnderlineThickness')
175
-            $info['UnderlineThickness'] = (int)$e[1];
176
-        elseif ($entry == 'UnderlinePosition')
177
-            $info['UnderlinePosition'] = (int)$e[1];
178
-        elseif ($entry == 'IsFixedPitch')
179
-            $info['IsFixedPitch'] = ($e[1] == 'true');
180
-        elseif ($entry == 'FontBBox')
181
-            $info['FontBBox'] = array((int)$e[1], (int)$e[2], (int)$e[3], (int)$e[4]);
182
-        elseif ($entry == 'CapHeight')
183
-            $info['CapHeight'] = (int)$e[1];
184
-        elseif ($entry == 'StdVW')
185
-            $info['StdVW'] = (int)$e[1];
177
+        } elseif ($entry == 'FontName') {
178
+                    $info['FontName'] = $e[1];
179
+        } elseif ($entry == 'Weight') {
180
+                    $info['Weight'] = $e[1];
181
+        } elseif ($entry == 'ItalicAngle') {
182
+                    $info['ItalicAngle'] = (int)$e[1];
183
+        } elseif ($entry == 'Ascender') {
184
+                    $info['Ascender'] = (int)$e[1];
185
+        } elseif ($entry == 'Descender') {
186
+                    $info['Descender'] = (int)$e[1];
187
+        } elseif ($entry == 'UnderlineThickness') {
188
+                    $info['UnderlineThickness'] = (int)$e[1];
189
+        } elseif ($entry == 'UnderlinePosition') {
190
+                    $info['UnderlinePosition'] = (int)$e[1];
191
+        } elseif ($entry == 'IsFixedPitch') {
192
+                    $info['IsFixedPitch'] = ($e[1] == 'true');
193
+        } elseif ($entry == 'FontBBox') {
194
+                    $info['FontBBox'] = array((int)$e[1], (int)$e[2], (int)$e[3], (int)$e[4]);
195
+        } elseif ($entry == 'CapHeight') {
196
+                    $info['CapHeight'] = (int)$e[1];
197
+        } elseif ($entry == 'StdVW') {
198
+                    $info['StdVW'] = (int)$e[1];
199
+        }
186 200
     }
187 201
 
188
-    if (!isset($info['FontName']))
189
-        Error('FontName missing in AFM file');
190
-    if (!isset($info['Ascender']))
191
-        $info['Ascender'] = $info['FontBBox'][3];
192
-    if (!isset($info['Descender']))
193
-        $info['Descender'] = $info['FontBBox'][1];
202
+    if (!isset($info['FontName'])) {
203
+            Error('FontName missing in AFM file');
204
+    }
205
+    if (!isset($info['Ascender'])) {
206
+            $info['Ascender'] = $info['FontBBox'][3];
207
+    }
208
+    if (!isset($info['Descender'])) {
209
+            $info['Descender'] = $info['FontBBox'][1];
210
+    }
194 211
     $info['Bold'] = isset($info['Weight']) && preg_match('/bold|black/i', $info['Weight']);
195
-    if (isset($cw['.notdef']))
196
-        $info['MissingWidth'] = $cw['.notdef'];
197
-    else
198
-        $info['MissingWidth'] = 0;
212
+    if (isset($cw['.notdef'])) {
213
+            $info['MissingWidth'] = $cw['.notdef'];
214
+    } else {
215
+            $info['MissingWidth'] = 0;
216
+    }
199 217
     $widths = array_fill(0, 256, $info['MissingWidth']);
200 218
     foreach ($map as $c => $v) {
201 219
         if ($v['name'] != '.notdef') {
202
-            if (isset($cw[$v['name']]))
203
-                $widths[$c] = $cw[$v['name']];
204
-            else
205
-                Warning('Character ' . $v['name'] . ' is missing');
220
+            if (isset($cw[$v['name']])) {
221
+                            $widths[$c] = $cw[$v['name']];
222
+            } else {
223
+                            Warning('Character ' . $v['name'] . ' is missing');
224
+            }
206 225
         }
207 226
     }
208 227
     $info['Widths'] = $widths;
@@ -216,17 +235,20 @@  discard block
 block discarded – undo
216 235
     // Descent
217 236
     $fd .= ",'Descent'=>" . $info['Descender'];
218 237
     // CapHeight
219
-    if (!empty($info['CapHeight']))
220
-        $fd .= ",'CapHeight'=>" . $info['CapHeight'];
221
-    else
222
-        $fd .= ",'CapHeight'=>" . $info['Ascender'];
238
+    if (!empty($info['CapHeight'])) {
239
+            $fd .= ",'CapHeight'=>" . $info['CapHeight'];
240
+    } else {
241
+            $fd .= ",'CapHeight'=>" . $info['Ascender'];
242
+    }
223 243
     // Flags
224 244
     $flags = 0;
225
-    if ($info['IsFixedPitch'])
226
-        $flags += 1 << 0;
245
+    if ($info['IsFixedPitch']) {
246
+            $flags += 1 << 0;
247
+    }
227 248
     $flags += 1 << 5;
228
-    if ($info['ItalicAngle'] != 0)
229
-        $flags += 1 << 6;
249
+    if ($info['ItalicAngle'] != 0) {
250
+            $flags += 1 << 6;
251
+    }
230 252
     $fd .= ",'Flags'=>" . $flags;
231 253
     // FontBBox
232 254
     $fbb = $info['FontBBox'];
@@ -234,12 +256,13 @@  discard block
 block discarded – undo
234 256
     // ItalicAngle
235 257
     $fd .= ",'ItalicAngle'=>" . $info['ItalicAngle'];
236 258
     // StemV
237
-    if (isset($info['StdVW']))
238
-        $stemv = $info['StdVW'];
239
-    elseif ($info['Bold'])
240
-        $stemv = 120;
241
-    else
242
-        $stemv = 70;
259
+    if (isset($info['StdVW'])) {
260
+            $stemv = $info['StdVW'];
261
+    } elseif ($info['Bold']) {
262
+            $stemv = 120;
263
+    } else {
264
+            $stemv = 70;
265
+    }
243 266
     $fd .= ",'StemV'=>" . $stemv;
244 267
     // MissingWidth
245 268
     $fd .= ",'MissingWidth'=>" . $info['MissingWidth'] . ')';
@@ -250,19 +273,22 @@  discard block
 block discarded – undo
250 273
 {
251 274
     $s = "array(\n\t";
252 275
     for ($c = 0; $c <= 255; $c++) {
253
-        if (chr($c) == "'")
254
-            $s .= "'\\''";
255
-        elseif (chr($c) == "\\")
256
-            $s .= "'\\\\'";
257
-        elseif ($c >= 32 && $c <= 126)
258
-            $s .= "'" . chr($c) . "'";
259
-        else
260
-            $s .= "chr($c)";
276
+        if (chr($c) == "'") {
277
+                    $s .= "'\\''";
278
+        } elseif (chr($c) == "\\") {
279
+                    $s .= "'\\\\'";
280
+        } elseif ($c >= 32 && $c <= 126) {
281
+                    $s .= "'" . chr($c) . "'";
282
+        } else {
283
+                    $s .= "chr($c)";
284
+        }
261 285
         $s .= '=>' . $widths[$c];
262
-        if ($c < 255)
263
-            $s .= ',';
264
-        if (($c + 1) % 22 == 0)
265
-            $s .= "\n\t";
286
+        if ($c < 255) {
287
+                    $s .= ',';
288
+        }
289
+        if (($c + 1) % 22 == 0) {
290
+                    $s .= "\n\t";
291
+        }
266 292
     }
267 293
     $s .= ')';
268 294
     return $s;
@@ -276,8 +302,9 @@  discard block
 block discarded – undo
276 302
     $last = 0;
277 303
     for ($c = 32; $c <= 255; $c++) {
278 304
         if ($map[$c]['name'] != $ref[$c]['name']) {
279
-            if ($c != $last + 1)
280
-                $s .= $c . ' ';
305
+            if ($c != $last + 1) {
306
+                            $s .= $c . ' ';
307
+            }
281 308
             $last = $c;
282 309
             $s .= '/' . $map[$c]['name'] . ' ';
283 310
         }
@@ -300,23 +327,26 @@  discard block
 block discarded – undo
300 327
                     $ranges[] = $range;
301 328
                     $range = array($c, $c, $uv, $uv);
302 329
                 }
303
-            } else
304
-                $range = array($c, $c, $uv, $uv);
330
+            } else {
331
+                            $range = array($c, $c, $uv, $uv);
332
+            }
305 333
         }
306 334
     }
307 335
     $ranges[] = $range;
308 336
 
309 337
     foreach ($ranges as $range) {
310
-        if (isset($s))
311
-            $s .= ',';
312
-        else
313
-            $s = 'array(';
338
+        if (isset($s)) {
339
+                    $s .= ',';
340
+        } else {
341
+                    $s = 'array(';
342
+        }
314 343
         $s .= $range[0] . '=>';
315 344
         $nb = $range[1] - $range[0] + 1;
316
-        if ($nb > 1)
317
-            $s .= 'array(' . $range[2] . ',' . $nb . ')';
318
-        else
319
-            $s .= $range[2];
345
+        if ($nb > 1) {
346
+                    $s .= 'array(' . $range[2] . ',' . $nb . ')';
347
+        } else {
348
+                    $s .= $range[2];
349
+        }
320 350
     }
321 351
     $s .= ')';
322 352
     return $s;
@@ -325,8 +355,9 @@  discard block
 block discarded – undo
325 355
 function SaveToFile($file, $s, $mode)
326 356
 {
327 357
     $f = fopen($file, 'w' . $mode);
328
-    if (!$f)
329
-        Error('Can\'t write to file ' . $file);
358
+    if (!$f) {
359
+            Error('Can\'t write to file ' . $file);
360
+    }
330 361
     fwrite($f, $s);
331 362
     fclose($f);
332 363
 }
@@ -342,8 +373,9 @@  discard block
 block discarded – undo
342 373
     $s .= '$cw = ' . MakeWidthArray($info['Widths']) . ";\n";
343 374
     $s .= '$enc = \'' . $enc . "';\n";
344 375
     $diff = MakeFontEncoding($map);
345
-    if ($diff)
346
-        $s .= '$diff = \'' . $diff . "';\n";
376
+    if ($diff) {
377
+            $s .= '$diff = \'' . $diff . "';\n";
378
+    }
347 379
     $s .= '$uv = ' . MakeUnicodeArray($map) . ";\n";
348 380
     if ($embed) {
349 381
         $s .= '$file = \'' . $info['File'] . "';\n";
@@ -352,8 +384,9 @@  discard block
 block discarded – undo
352 384
             $s .= '$size2 = ' . $info['Size2'] . ";\n";
353 385
         } else {
354 386
             $s .= '$originalsize = ' . $info['OriginalSize'] . ";\n";
355
-            if ($subset)
356
-                $s .= "\$subsetted = true;\n";
387
+            if ($subset) {
388
+                            $s .= "\$subsetted = true;\n";
389
+            }
357 390
         }
358 391
     }
359 392
     $s .= "?>\n";
@@ -363,26 +396,30 @@  discard block
 block discarded – undo
363 396
 function MakeFont($fontfile, $enc = 'cp1252', $embed = true, $subset = true)
364 397
 {
365 398
     // Generate a font definition file
366
-    if (get_magic_quotes_runtime())
367
-        @set_magic_quotes_runtime(false);
399
+    if (get_magic_quotes_runtime()) {
400
+            @set_magic_quotes_runtime(false);
401
+    }
368 402
     ini_set('auto_detect_line_endings', '1');
369 403
 
370
-    if (!file_exists($fontfile))
371
-        Error('Font file not found: ' . $fontfile);
404
+    if (!file_exists($fontfile)) {
405
+            Error('Font file not found: ' . $fontfile);
406
+    }
372 407
     $ext = strtolower(substr($fontfile, -3));
373
-    if ($ext == 'ttf' || $ext == 'otf')
374
-        $type = 'TrueType';
375
-    elseif ($ext == 'pfb')
376
-        $type = 'Type1';
377
-    else
378
-        Error('Unrecognized font file extension: ' . $ext);
408
+    if ($ext == 'ttf' || $ext == 'otf') {
409
+            $type = 'TrueType';
410
+    } elseif ($ext == 'pfb') {
411
+            $type = 'Type1';
412
+    } else {
413
+            Error('Unrecognized font file extension: ' . $ext);
414
+    }
379 415
 
380 416
     $map = LoadMap($enc);
381 417
 
382
-    if ($type == 'TrueType')
383
-        $info = GetInfoFromTrueType($fontfile, $embed, $subset, $map);
384
-    else
385
-        $info = GetInfoFromType1($fontfile, $embed, $map);
418
+    if ($type == 'TrueType') {
419
+            $info = GetInfoFromTrueType($fontfile, $embed, $subset, $map);
420
+    } else {
421
+            $info = GetInfoFromType1($fontfile, $embed, $map);
422
+    }
386 423
 
387 424
     $basename = substr(basename($fontfile), 0, -4);
388 425
     if ($embed) {
@@ -405,21 +442,25 @@  discard block
 block discarded – undo
405 442
 if (PHP_SAPI == 'cli') {
406 443
     // Command-line interface
407 444
     ini_set('log_errors', '0');
408
-    if ($argc == 1)
409
-        die("Usage: php makefont.php fontfile [encoding] [embed] [subset]\n");
445
+    if ($argc == 1) {
446
+            die("Usage: php makefont.php fontfile [encoding] [embed] [subset]\n");
447
+    }
410 448
     $fontfile = $argv[1];
411
-    if ($argc >= 3)
412
-        $enc = $argv[2];
413
-    else
414
-        $enc = 'cp1252';
415
-    if ($argc >= 4)
416
-        $embed = ($argv[3] == 'true' || $argv[3] == '1');
417
-    else
418
-        $embed = true;
419
-    if ($argc >= 5)
420
-        $subset = ($argv[4] == 'true' || $argv[4] == '1');
421
-    else
422
-        $subset = true;
449
+    if ($argc >= 3) {
450
+            $enc = $argv[2];
451
+    } else {
452
+            $enc = 'cp1252';
453
+    }
454
+    if ($argc >= 4) {
455
+            $embed = ($argv[3] == 'true' || $argv[3] == '1');
456
+    } else {
457
+            $embed = true;
458
+    }
459
+    if ($argc >= 5) {
460
+            $subset = ($argv[4] == 'true' || $argv[4] == '1');
461
+    } else {
462
+            $subset = true;
463
+    }
423 464
     MakeFont($fontfile, $enc, $embed, $subset);
424 465
 }
425 466
 ?>
Please login to merge, or discard this patch.
src/Ballybran/Library/fpdf/makefont/ttfparser.php 1 patch
Braces   +156 added lines, -106 removed lines patch added patch discarded remove patch
@@ -51,14 +51,16 @@  discard block
 block discarded – undo
51 51
     function __construct($file)
52 52
     {
53 53
         $this->f = fopen($file, 'rb');
54
-        if (!$this->f)
55
-            $this->Error('Can\'t open file: ' . $file);
54
+        if (!$this->f) {
55
+                    $this->Error('Can\'t open file: ' . $file);
56
+        }
56 57
     }
57 58
 
58 59
     function __destruct()
59 60
     {
60
-        if (is_resource($this->f))
61
-            fclose($this->f);
61
+        if (is_resource($this->f)) {
62
+                    fclose($this->f);
63
+        }
62 64
     }
63 65
 
64 66
     function Parse()
@@ -79,10 +81,12 @@  discard block
 block discarded – undo
79 81
     function ParseOffsetTable()
80 82
     {
81 83
         $version = $this->Read(4);
82
-        if ($version == 'OTTO')
83
-            $this->Error('OpenType fonts based on PostScript outlines are not supported');
84
-        if ($version != "\x00\x01\x00\x00")
85
-            $this->Error('Unrecognized file format');
84
+        if ($version == 'OTTO') {
85
+                    $this->Error('OpenType fonts based on PostScript outlines are not supported');
86
+        }
87
+        if ($version != "\x00\x01\x00\x00") {
88
+                    $this->Error('Unrecognized file format');
89
+        }
86 90
         $numTables = $this->ReadUShort();
87 91
         $this->Skip(3 * 2); // searchRange, entrySelector, rangeShift
88 92
         $this->tables = array();
@@ -100,8 +104,9 @@  discard block
 block discarded – undo
100 104
         $this->Seek('head');
101 105
         $this->Skip(3 * 4); // version, fontRevision, checkSumAdjustment
102 106
         $magicNumber = $this->ReadULong();
103
-        if ($magicNumber != 0x5F0F3CF5)
104
-            $this->Error('Incorrect magic number');
107
+        if ($magicNumber != 0x5F0F3CF5) {
108
+                    $this->Error('Incorrect magic number');
109
+        }
105 110
         $this->Skip(2); // flags
106 111
         $this->unitsPerEm = $this->ReadUShort();
107 112
         $this->Skip(2 * 8); // created, modified
@@ -148,12 +153,14 @@  discard block
 block discarded – undo
148 153
         $offsets = array();
149 154
         if ($this->indexToLocFormat == 0) {
150 155
             // Short format
151
-            for ($i = 0; $i <= $this->numGlyphs; $i++)
152
-                $offsets[] = 2 * $this->ReadUShort();
156
+            for ($i = 0; $i <= $this->numGlyphs; $i++) {
157
+                            $offsets[] = 2 * $this->ReadUShort();
158
+            }
153 159
         } else {
154 160
             // Long format
155
-            for ($i = 0; $i <= $this->numGlyphs; $i++)
156
-                $offsets[] = $this->ReadULong();
161
+            for ($i = 0; $i <= $this->numGlyphs; $i++) {
162
+                            $offsets[] = $this->ReadULong();
163
+            }
157 164
         }
158 165
         for ($i = 0; $i < $this->numGlyphs; $i++) {
159 166
             $this->glyphs[$i]['offset'] = $offsets[$i];
@@ -176,16 +183,22 @@  discard block
 block discarded – undo
176 183
                         $flags = $this->ReadUShort();
177 184
                         $index = $this->ReadUShort();
178 185
                         $a[$offset + 2] = $index;
179
-                        if ($flags & 1) // ARG_1_AND_2_ARE_WORDS
180
-                            $skip = 2 * 2;
181
-                        else
182
-                            $skip = 2;
183
-                        if ($flags & 8) // WE_HAVE_A_SCALE
184
-                            $skip += 2;
185
-                        elseif ($flags & 64) // WE_HAVE_AN_X_AND_Y_SCALE
186
-                            $skip += 2 * 2;
187
-                        elseif ($flags & 128) // WE_HAVE_A_TWO_BY_TWO
188
-                            $skip += 4 * 2;
186
+                        if ($flags & 1) {
187
+                            // ARG_1_AND_2_ARE_WORDS
188
+                            $skip = 2 * 2;
189
+                        } else {
190
+                                                    $skip = 2;
191
+                        }
192
+                        if ($flags & 8) {
193
+                            // WE_HAVE_A_SCALE
194
+                            $skip += 2;
195
+                        } elseif ($flags & 64) {
196
+                            // WE_HAVE_AN_X_AND_Y_SCALE
197
+                            $skip += 2 * 2;
198
+                        } elseif ($flags & 128) {
199
+                            // WE_HAVE_A_TWO_BY_TWO
200
+                            $skip += 4 * 2;
201
+                        }
189 202
                         $this->Skip($skip);
190 203
                         $offset += 2 * 2 + $skip;
191 204
                     } while ($flags & 32); // MORE_COMPONENTS
@@ -205,11 +218,13 @@  discard block
 block discarded – undo
205 218
             $platformID = $this->ReadUShort();
206 219
             $encodingID = $this->ReadUShort();
207 220
             $offset = $this->ReadULong();
208
-            if ($platformID == 3 && $encodingID == 1)
209
-                $offset31 = $offset;
221
+            if ($platformID == 3 && $encodingID == 1) {
222
+                            $offset31 = $offset;
223
+            }
210 224
         }
211
-        if ($offset31 == 0)
212
-            $this->Error('No Unicode encoding found');
225
+        if ($offset31 == 0) {
226
+                    $this->Error('No Unicode encoding found');
227
+        }
213 228
 
214 229
         $startCount = array();
215 230
         $endCount = array();
@@ -218,42 +233,53 @@  discard block
 block discarded – undo
218 233
         $this->chars = array();
219 234
         fseek($this->f, $this->tables['cmap']['offset'] + $offset31, SEEK_SET);
220 235
         $format = $this->ReadUShort();
221
-        if ($format != 4)
222
-            $this->Error('Unexpected subtable format: ' . $format);
236
+        if ($format != 4) {
237
+                    $this->Error('Unexpected subtable format: ' . $format);
238
+        }
223 239
         $this->Skip(2 * 2); // length, language
224 240
         $segCount = $this->ReadUShort() / 2;
225 241
         $this->Skip(3 * 2); // searchRange, entrySelector, rangeShift
226
-        for ($i = 0; $i < $segCount; $i++)
227
-            $endCount[$i] = $this->ReadUShort();
242
+        for ($i = 0; $i < $segCount; $i++) {
243
+                    $endCount[$i] = $this->ReadUShort();
244
+        }
228 245
         $this->Skip(2); // reservedPad
229
-        for ($i = 0; $i < $segCount; $i++)
230
-            $startCount[$i] = $this->ReadUShort();
231
-        for ($i = 0; $i < $segCount; $i++)
232
-            $idDelta[$i] = $this->ReadShort();
246
+        for ($i = 0; $i < $segCount; $i++) {
247
+                    $startCount[$i] = $this->ReadUShort();
248
+        }
249
+        for ($i = 0; $i < $segCount; $i++) {
250
+                    $idDelta[$i] = $this->ReadShort();
251
+        }
233 252
         $offset = ftell($this->f);
234
-        for ($i = 0; $i < $segCount; $i++)
235
-            $idRangeOffset[$i] = $this->ReadUShort();
253
+        for ($i = 0; $i < $segCount; $i++) {
254
+                    $idRangeOffset[$i] = $this->ReadUShort();
255
+        }
236 256
 
237 257
         for ($i = 0; $i < $segCount; $i++) {
238 258
             $c1 = $startCount[$i];
239 259
             $c2 = $endCount[$i];
240 260
             $d = $idDelta[$i];
241 261
             $ro = $idRangeOffset[$i];
242
-            if ($ro > 0)
243
-                fseek($this->f, $offset + 2 * $i + $ro, SEEK_SET);
262
+            if ($ro > 0) {
263
+                            fseek($this->f, $offset + 2 * $i + $ro, SEEK_SET);
264
+            }
244 265
             for ($c = $c1; $c <= $c2; $c++) {
245
-                if ($c == 0xFFFF)
246
-                    break;
266
+                if ($c == 0xFFFF) {
267
+                                    break;
268
+                }
247 269
                 if ($ro > 0) {
248 270
                     $gid = $this->ReadUShort();
249
-                    if ($gid > 0)
250
-                        $gid += $d;
251
-                } else
252
-                    $gid = $c + $d;
253
-                if ($gid >= 65536)
254
-                    $gid -= 65536;
255
-                if ($gid > 0)
256
-                    $this->chars[$c] = $gid;
271
+                    if ($gid > 0) {
272
+                                            $gid += $d;
273
+                    }
274
+                } else {
275
+                                    $gid = $c + $d;
276
+                }
277
+                if ($gid >= 65536) {
278
+                                    $gid -= 65536;
279
+                }
280
+                if ($gid > 0) {
281
+                                    $this->chars[$c] = $gid;
282
+                }
257 283
             }
258 284
         }
259 285
     }
@@ -281,8 +307,9 @@  discard block
 block discarded – undo
281 307
                 break;
282 308
             }
283 309
         }
284
-        if ($this->postScriptName == '')
285
-            $this->Error('PostScript name not found');
310
+        if ($this->postScriptName == '') {
311
+                    $this->Error('PostScript name not found');
312
+        }
286 313
     }
287 314
 
288 315
     function ParseOS2()
@@ -301,8 +328,9 @@  discard block
 block discarded – undo
301 328
         if ($version >= 2) {
302 329
             $this->Skip(3 * 2 + 2 * 4 + 2);
303 330
             $this->capHeight = $this->ReadShort();
304
-        } else
305
-            $this->capHeight = 0;
331
+        } else {
332
+                    $this->capHeight = 0;
333
+        }
306 334
     }
307 335
 
308 336
     function ParsePost()
@@ -324,22 +352,25 @@  discard block
 block discarded – undo
324 352
             for ($i = 0; $i < $this->numGlyphs; $i++) {
325 353
                 $index = $this->ReadUShort();
326 354
                 $glyphNameIndex[] = $index;
327
-                if ($index >= 258 && $index - 257 > $numNames)
328
-                    $numNames = $index - 257;
355
+                if ($index >= 258 && $index - 257 > $numNames) {
356
+                                    $numNames = $index - 257;
357
+                }
329 358
             }
330 359
             for ($i = 0; $i < $numNames; $i++) {
331 360
                 $len = ord($this->Read(1));
332 361
                 $names[] = $this->Read($len);
333 362
             }
334 363
             foreach ($glyphNameIndex as $i => $index) {
335
-                if ($index >= 258)
336
-                    $this->glyphs[$i]['name'] = $names[$index - 258];
337
-                else
338
-                    $this->glyphs[$i]['name'] = $index;
364
+                if ($index >= 258) {
365
+                                    $this->glyphs[$i]['name'] = $names[$index - 258];
366
+                } else {
367
+                                    $this->glyphs[$i]['name'] = $index;
368
+                }
339 369
             }
340 370
             $this->glyphNames = true;
341
-        } else
342
-            $this->glyphNames = false;
371
+        } else {
372
+                    $this->glyphNames = false;
373
+        }
343 374
     }
344 375
 
345 376
     function Subset($chars)
@@ -369,8 +400,9 @@  discard block
 block discarded – undo
369 400
             $this->glyphs[$id]['ssid'] = count($this->subsettedGlyphs);
370 401
             $this->subsettedGlyphs[] = $id;
371 402
             if (isset($this->glyphs[$id]['components'])) {
372
-                foreach ($this->glyphs[$id]['components'] as $cid)
373
-                    $this->AddGlyph($cid);
403
+                foreach ($this->glyphs[$id]['components'] as $cid) {
404
+                                    $this->AddGlyph($cid);
405
+                }
374 406
             }
375 407
         }
376 408
     }
@@ -389,8 +421,9 @@  discard block
 block discarded – undo
389 421
 
390 422
     function BuildCmap()
391 423
     {
392
-        if (!isset($this->subsettedChars))
393
-            return;
424
+        if (!isset($this->subsettedChars)) {
425
+                    return;
426
+        }
394 427
 
395 428
         // Divide charset in contiguous segments
396 429
         $chars = $this->subsettedChars;
@@ -401,8 +434,9 @@  discard block
 block discarded – undo
401 434
             if ($chars[$i] > $segment[1] + 1) {
402 435
                 $segments[] = $segment;
403 436
                 $segment = array($chars[$i], $chars[$i]);
404
-            } else
405
-                $segment[1]++;
437
+            } else {
438
+                            $segment[1]++;
439
+            }
406 440
         }
407 441
         $segments[] = $segment;
408 442
         $segments[] = array(0xFFFF, 0xFFFF);
@@ -428,10 +462,11 @@  discard block
 block discarded – undo
428 462
                 }
429 463
             } else {
430 464
                 // Segment with a single char
431
-                if ($start < 0xFFFF)
432
-                    $ssid = $this->glyphs[$this->chars[$start]]['ssid'];
433
-                else
434
-                    $ssid = 0;
465
+                if ($start < 0xFFFF) {
466
+                                    $ssid = $this->glyphs[$this->chars[$start]]['ssid'];
467
+                } else {
468
+                                    $ssid = 0;
469
+                }
435 470
                 $idDelta[] = $ssid - $start;
436 471
                 $idRangeOffset[] = 0;
437 472
             }
@@ -445,15 +480,19 @@  discard block
 block discarded – undo
445 480
         $searchRange = (1 << $entrySelector) * 2;
446 481
         $rangeShift = 2 * $segCount - $searchRange;
447 482
         $cmap = pack('nnnn', 2 * $segCount, $searchRange, $entrySelector, $rangeShift);
448
-        foreach ($endCount as $val)
449
-            $cmap .= pack('n', $val);
483
+        foreach ($endCount as $val) {
484
+                    $cmap .= pack('n', $val);
485
+        }
450 486
         $cmap .= pack('n', 0); // reservedPad
451
-        foreach ($startCount as $val)
452
-            $cmap .= pack('n', $val);
453
-        foreach ($idDelta as $val)
454
-            $cmap .= pack('n', $val);
455
-        foreach ($idRangeOffset as $val)
456
-            $cmap .= pack('n', $val);
487
+        foreach ($startCount as $val) {
488
+                    $cmap .= pack('n', $val);
489
+        }
490
+        foreach ($idDelta as $val) {
491
+                    $cmap .= pack('n', $val);
492
+        }
493
+        foreach ($idRangeOffset as $val) {
494
+                    $cmap .= pack('n', $val);
495
+        }
457 496
         $cmap .= $glyphIdArray;
458 497
 
459 498
         $data = pack('nn', 0, 1); // version, numTables
@@ -486,16 +525,18 @@  discard block
 block discarded – undo
486 525
         $data = '';
487 526
         $offset = 0;
488 527
         foreach ($this->subsettedGlyphs as $id) {
489
-            if ($this->indexToLocFormat == 0)
490
-                $data .= pack('n', $offset / 2);
491
-            else
492
-                $data .= pack('N', $offset);
528
+            if ($this->indexToLocFormat == 0) {
529
+                            $data .= pack('n', $offset / 2);
530
+            } else {
531
+                            $data .= pack('N', $offset);
532
+            }
493 533
             $offset += $this->glyphs[$id]['length'];
494 534
         }
495
-        if ($this->indexToLocFormat == 0)
496
-            $data .= pack('n', $offset / 2);
497
-        else
498
-            $data .= pack('N', $offset);
535
+        if ($this->indexToLocFormat == 0) {
536
+                    $data .= pack('n', $offset / 2);
537
+        } else {
538
+                    $data .= pack('N', $offset);
539
+        }
499 540
         $this->SetTable('loca', $data);
500 541
     }
501 542
 
@@ -543,8 +584,9 @@  discard block
 block discarded – undo
543 584
                     $data .= pack('n', 258 + $numNames);
544 585
                     $names .= chr(strlen($name)) . $name;
545 586
                     $numNames++;
546
-                } else
547
-                    $data .= pack('n', $name);
587
+                } else {
588
+                                    $data .= pack('n', $name);
589
+                }
548 590
             }
549 591
             $data .= $names;
550 592
         } else {
@@ -560,14 +602,16 @@  discard block
 block discarded – undo
560 602
     {
561 603
         $tags = array();
562 604
         foreach (array('cmap', 'cvt ', 'fpgm', 'glyf', 'head', 'hhea', 'hmtx', 'loca', 'maxp', 'name', 'post', 'prep') as $tag) {
563
-            if (isset($this->tables[$tag]))
564
-                $tags[] = $tag;
605
+            if (isset($this->tables[$tag])) {
606
+                            $tags[] = $tag;
607
+            }
565 608
         }
566 609
         $numTables = count($tags);
567 610
         $offset = 12 + 16 * $numTables;
568 611
         foreach ($tags as $tag) {
569
-            if (!isset($this->tables[$tag]['data']))
570
-                $this->LoadTable($tag);
612
+            if (!isset($this->tables[$tag]['data'])) {
613
+                            $this->LoadTable($tag);
614
+            }
571 615
             $this->tables[$tag]['offset'] = $offset;
572 616
             $offset += strlen($this->tables[$tag]['data']);
573 617
         }
@@ -589,8 +633,9 @@  discard block
 block discarded – undo
589 633
 
590 634
         // Compute checkSumAdjustment (0xB1B0AFBA - font checkSum)
591 635
         $s = $this->CheckSum($offsetTable);
592
-        foreach ($tags as $tag)
593
-            $s .= $this->tables[$tag]['checkSum'];
636
+        foreach ($tags as $tag) {
637
+                    $s .= $this->tables[$tag]['checkSum'];
638
+        }
594 639
         $a = unpack('n2', $this->CheckSum($s));
595 640
         $high = 0xB1B0 + ($a[1] ^ 0xFFFF);
596 641
         $low = 0xAFBA + ($a[2] ^ 0xFFFF) + 1;
@@ -598,8 +643,9 @@  discard block
 block discarded – undo
598 643
         $this->tables['head']['data'] = substr_replace($this->tables['head']['data'], $checkSumAdjustment, 8, 4);
599 644
 
600 645
         $font = $offsetTable;
601
-        foreach ($tags as $tag)
602
-            $font .= $this->tables[$tag]['data'];
646
+        foreach ($tags as $tag) {
647
+                    $font .= $this->tables[$tag]['data'];
648
+        }
603 649
 
604 650
         return $font;
605 651
     }
@@ -609,8 +655,9 @@  discard block
 block discarded – undo
609 655
         $this->Seek($tag);
610 656
         $length = $this->tables[$tag]['length'];
611 657
         $n = $length % 4;
612
-        if ($n > 0)
613
-            $length += 4 - $n;
658
+        if ($n > 0) {
659
+                    $length += 4 - $n;
660
+        }
614 661
         $this->tables[$tag]['data'] = $this->Read($length);
615 662
     }
616 663
 
@@ -618,8 +665,9 @@  discard block
 block discarded – undo
618 665
     {
619 666
         $length = strlen($data);
620 667
         $n = $length % 4;
621
-        if ($n > 0)
622
-            $data = str_pad($data, $length + 4 - $n, "\x00");
668
+        if ($n > 0) {
669
+                    $data = str_pad($data, $length + 4 - $n, "\x00");
670
+        }
623 671
         $this->tables[$tag]['data'] = $data;
624 672
         $this->tables[$tag]['length'] = $length;
625 673
         $this->tables[$tag]['checkSum'] = $this->CheckSum($data);
@@ -627,8 +675,9 @@  discard block
 block discarded – undo
627 675
 
628 676
     function Seek($tag)
629 677
     {
630
-        if (!isset($this->tables[$tag]))
631
-            $this->Error('Table not found: ' . $tag);
678
+        if (!isset($this->tables[$tag])) {
679
+                    $this->Error('Table not found: ' . $tag);
680
+        }
632 681
         fseek($this->f, $this->tables[$tag]['offset'], SEEK_SET);
633 682
     }
634 683
 
@@ -652,8 +701,9 @@  discard block
 block discarded – undo
652 701
     {
653 702
         $a = unpack('nn', fread($this->f, 2));
654 703
         $v = $a['n'];
655
-        if ($v >= 0x8000)
656
-            $v -= 65536;
704
+        if ($v >= 0x8000) {
705
+                    $v -= 65536;
706
+        }
657 707
         return $v;
658 708
     }
659 709
 
Please login to merge, or discard this patch.
src/Ballybran/Library/Graphic/PHPGraphLibPie.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -54,7 +54,7 @@
 block discarded – undo
54 54
     const PIE_WIDTH_PERCENT = 75; //default width % of total width
55 55
     const PIE_HEIGHT_PERCENT = 28;
56 56
     const PIE_LABEL_SCALE = 90; //in % scale width/height if data labels
57
-    const PIE_LEGEND_SCALE = 64;//in % scale width/height if legend
57
+    const PIE_LEGEND_SCALE = 64; //in % scale width/height if legend
58 58
 
59 59
     //internals - do not change
60 60
     protected $pie_width;
Please login to merge, or discard this patch.
src/Ballybran/Exception/KException.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -99,7 +99,7 @@
 block discarded – undo
99 99
 {
100 100
     echo $message;
101 101
 }
102
-public static function error($params = null){ ?>
102
+public static function error($params = null) { ?>
103 103
 
104 104
 <!DOCTYPE html>
105 105
 <html lang="pt">
Please login to merge, or discard this patch.