kingkay000 commited on
Commit
58e54c4
·
verified ·
1 Parent(s): ac4c784

Upload ReceiptGenerator.php

Browse files
easypay/includes/ReceiptGenerator.php CHANGED
@@ -58,7 +58,7 @@ class ReceiptGenerator
58
  $targetW = 100;
59
  $targetH = ($targetW / $logoW) * $logoH;
60
 
61
- imagecopyresampled($image, $logo, 40, 30, 0, 0, $targetW, $targetH, $logoW, $logoH);
62
  }
63
  }
64
 
@@ -184,8 +184,8 @@ class ReceiptGenerator
184
  try {
185
  $box = imagettfbbox($size, 0, $this->fontPath, $text);
186
  $textW = $box[2] - $box[0];
187
- $x = (imagesx($image) - $textW) / 2;
188
- imagettftext($image, $size, 0, $x, $y, $color, $this->fontPath, $text);
189
  return;
190
  } catch (Exception $e) {
191
  // Fallthrough to built-in font
@@ -196,8 +196,8 @@ class ReceiptGenerator
196
  $gdSize = min(5, max(1, floor($size / 3)));
197
  $charWidth = imagefontwidth($gdSize);
198
  $textW = strlen($text) * $charWidth;
199
- $x = (imagesx($image) - $textW) / 2;
200
- imagestring($image, $gdSize, $x, $y, $text, $color);
201
  }
202
 
203
  private function rightAlignText($image, $size, $rightX, $y, $text, $color)
@@ -206,8 +206,8 @@ class ReceiptGenerator
206
  try {
207
  $box = imagettfbbox($size, 0, $this->fontPath, $text);
208
  $textW = $box[2] - $box[0];
209
- $x = $rightX - $textW;
210
- imagettftext($image, $size, 0, $x, $y, $color, $this->fontPath, $text);
211
  return;
212
  } catch (Exception $e) {
213
  // Fallthrough
@@ -215,7 +215,7 @@ class ReceiptGenerator
215
  }
216
  $gdSize = min(5, max(1, floor($size / 3)));
217
  $charWidth = imagefontwidth($gdSize);
218
- $x = $rightX - (strlen($text) * $charWidth);
219
- imagestring($image, $gdSize, $x, $y, $text, $color);
220
  }
221
  }
 
58
  $targetW = 100;
59
  $targetH = ($targetW / $logoW) * $logoH;
60
 
61
+ imagecopyresampled($image, $logo, 40, 30, 0, 0, $targetW, (int) $targetH, $logoW, $logoH);
62
  }
63
  }
64
 
 
184
  try {
185
  $box = imagettfbbox($size, 0, $this->fontPath, $text);
186
  $textW = $box[2] - $box[0];
187
+ $x = (int) ((imagesx($image) - $textW) / 2);
188
+ imagettftext($image, $size, 0, $x, (int) $y, $color, $this->fontPath, $text);
189
  return;
190
  } catch (Exception $e) {
191
  // Fallthrough to built-in font
 
196
  $gdSize = min(5, max(1, floor($size / 3)));
197
  $charWidth = imagefontwidth($gdSize);
198
  $textW = strlen($text) * $charWidth;
199
+ $x = (int) ((imagesx($image) - $textW) / 2);
200
+ imagestring($image, $gdSize, $x, (int) $y, $text, $color);
201
  }
202
 
203
  private function rightAlignText($image, $size, $rightX, $y, $text, $color)
 
206
  try {
207
  $box = imagettfbbox($size, 0, $this->fontPath, $text);
208
  $textW = $box[2] - $box[0];
209
+ $x = (int) ($rightX - $textW);
210
+ imagettftext($image, $size, 0, $x, (int) $y, $color, $this->fontPath, $text);
211
  return;
212
  } catch (Exception $e) {
213
  // Fallthrough
 
215
  }
216
  $gdSize = min(5, max(1, floor($size / 3)));
217
  $charWidth = imagefontwidth($gdSize);
218
+ $x = (int) ($rightX - (strlen($text) * $charWidth));
219
+ imagestring($image, $gdSize, $x, (int) $y, $text, $color);
220
  }
221
  }