From c101b2b980efcb22f58e83b7017d55db05775fde Mon Sep 17 00:00:00 2001 From: Thibault Richy Date: Tue, 12 Mar 2019 15:49:26 +0100 Subject: [PATCH] Fix for ww --- app/Traits/GenerateBR.php | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/app/Traits/GenerateBR.php b/app/Traits/GenerateBR.php index 91f0ed2..9622fb1 100644 --- a/app/Traits/GenerateBR.php +++ b/app/Traits/GenerateBR.php @@ -118,17 +118,29 @@ trait GenerateBR { // ---- Inscription produit valable $textReduc = $coupon->coupon_validity_text; - $ImageFond = imagecreate(387, 200); - $white = imagecolorallocate($ImageFond, 255, 255, 255); - $black = imagecolorallocate($ImageFond, 0, 0, 0); - - $textReducs = explode("\r\n", $textReduc); - $y = 14; - foreach ($textReducs as $textReduc) { - $this->imagettftextSp($ImageFond , 12 , 0, 0, $y, $black, $arialbd, $textReduc, 0.01); - $y= $y+18; + if(strlen($textReduc) < 100) { + $ImageFond = imagecreate(387, 200); + $white = imagecolorallocate($ImageFond, 255, 255, 255); + $black = imagecolorallocate($ImageFond, 0, 0, 0); + + $textReducs = explode("\r\n", $textReduc); + $y = 14; + foreach ($textReducs as $textReduc) { + $this->imagettftextSp($ImageFond , 12 , 0, 0, $y, $black, $arialbd, $textReduc, 0.01); + $y= $y+18; + } + } else { + $ImageFond = imagecreate(387, 200); + $white = imagecolorallocate($ImageFond, 255, 255, 255); + $black = imagecolorallocate($ImageFond, 0, 0, 0); + + $textReducs = explode("\r\n", $textReduc); + $y = 14; + foreach ($textReducs as $textReduc) { + $this->imagettftextSp($ImageFond , 10 , 0, 0, $y, $black, $arialbd, $textReduc, 0.01); + $y= $y+12; + } } - //imagettftext($ImageFond , 12 , 0, 0, 14, $black, $arialbd, $textReduc); imagecolortransparent($ImageFond, $white); imagecopy($mask, $ImageFond, 360, 170, 0, 0, imagesx($ImageFond), imagesy($ImageFond));