Skip to content

Commit

Permalink
Text position fix
Browse files Browse the repository at this point in the history
  • Loading branch information
zertex committed Jul 17, 2022
1 parent 425790e commit 1caa4cf
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Avatar.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ public function text(): self
$parts = explode(' ', $this->username);
$text = is_array($parts) && count($parts)>1 ? mb_substr($parts[0],0,1,"UTF-8") . mb_substr($parts[1],0,1,"UTF-8") : mb_substr($this->username,0,2,"UTF-8");
$box = imageftbbox( $this->options->font_size, 0, $this->options->font, $text);
$x = (500 - ($box[2] - $box[0])) / 2;
$y = (500 - ($box[1] - $box[7])) / 2;
$x = round((500 - ($box[2] - $box[0])) / 2);
$y = round((500 - ($box[1] - $box[7])) / 2);
$y -= $box[7];
imagettftext($this->img, $this->options->font_size, 0, $x, $y, $this->color_allocate, $this->options->font, $text);
return $this;
Expand Down

0 comments on commit 1caa4cf

Please sign in to comment.