5 use \Intervention\Image\Image;
16 return intval(ceil($this->
size * 0.75));
24 private function getInternalFont()
27 $internalfont = is_numeric($internalfont) ? $internalfont :
false;
29 if ( ! in_array($internalfont, array(1, 2, 3, 4, 5))) {
30 throw new \Intervention\Image\Exception\NotSupportedException(
31 sprintf(
'Internal GD font (%s) not available. Use only 1-5.', $internalfont)
35 return intval($internalfont);
43 private function getInternalFontWidth()
45 return $this->getInternalFont() + 4;
53 private function getInternalFontHeight()
55 switch ($this->getInternalFont()) {
88 if ($this->
angle != 0) {
92 for ($i=0; $i<4; $i++) {
94 $y = $box[$i * 2 + 1];
100 $box[
'width'] = intval(abs($box[4] - $box[0]));
101 $box[
'height'] = intval(abs($box[5] - $box[1]));
106 $width = $this->getInternalFontWidth();
107 $height = $this->getInternalFontHeight();
109 if (strlen($this->
text) == 0) {
115 $box[
'width'] = strlen($this->
text) * $width;
116 $box[
'height'] = $height;
138 if ($this->
angle != 0 || is_string($this->
align) || is_string($this->
valign)) {
149 $posx = $posx - round(($box[6]+$box[4])/2);
150 $posy = $posy - round(($box[7]+$box[5])/2);
154 $posx = $posx - $box[4];
155 $posy = $posy - $box[5];
159 $posx = $posx - $box[6];
160 $posy = $posy - $box[7];
163 case 'center-center':
164 case 'center-middle':
165 $posx = $posx - round(($box[0]+$box[4])/2);
166 $posy = $posy - round(($box[1]+$box[5])/2);
171 $posx = $posx - round(($box[2]+$box[4])/2);
172 $posy = $posy - round(($box[3]+$box[5])/2);
177 $posx = $posx - round(($box[0]+$box[6])/2);
178 $posy = $posy - round(($box[1]+$box[7])/2);
181 case 'center-bottom':
182 $posx = $posx - round(($box[0]+$box[2])/2);
183 $posy = $posy - round(($box[1]+$box[3])/2);
187 $posx = $posx - $box[2];
188 $posy = $posy - $box[3];
192 $posx = $posx - $box[0];
193 $posy = $posy - $box[1];
199 imagealphablending($image->
getCore(),
true);
202 imagettftext($image->
getCore(), $this->getPointSize(), $this->angle, $posx, $posy,
$color->getInt(), $this->file, $this->text);
208 $width = $box[
'width'];
209 $height = $box[
'height'];
212 if ($this->getInternalFont() == 1) {
214 $bottom_correction = 2;
215 } elseif ($this->getInternalFont() == 3) {
217 $bottom_correction = 4;
220 $bottom_correction = 4;
224 switch (strtolower($this->
align)) {
226 $posx = ceil($posx - ($width / 2));
230 $posx = ceil($posx - $width) + 1;
235 switch (strtolower($this->
valign)) {
238 $posy = ceil($posy - ($height / 2));
242 $posy = ceil($posy - $top_correction);
247 $posy = round($posy - $height + $bottom_correction);
252 imagestring($image->
getCore(), $this->getInternalFont(), $posx, $posy, $this->text,
$color->getInt());