diff --git a/src/InitialAvatar.php b/src/InitialAvatar.php index a9b5611..a174c9f 100644 --- a/src/InitialAvatar.php +++ b/src/InitialAvatar.php @@ -24,21 +24,22 @@ class InitialAvatar /** @var Initials */ protected $initials_generator; - protected $driver = 'gd'; // imagick or gd - protected $fontSize = 0.5; - protected $name = 'John Doe'; - protected $width = 48; - protected $height = 48; - protected $bgColor = '#f0e9e9'; - protected $fontColor = '#8b5d5d'; - protected $rounded = false; - protected $smooth = false; - protected $autofont = false; - protected $keepCase = false; - protected $fontFile = '/fonts/OpenSans-Regular.ttf'; - protected $fontName = 'OpenSans, sans-serif'; - protected $generated_initials = 'JD'; - protected $preferBold = false; + protected $driver = 'gd'; // imagick or gd + protected $fontSize = 0.5; + protected $name = 'John Doe'; + protected $width = 48; + protected $height = 48; + protected $bgColor = '#f0e9e9'; + protected $fontColor = '#8b5d5d'; + protected $rounded = false; + protected $smooth = false; + protected $autofont = false; + protected $keepCase = false; + protected $allowSpecialCharacters = true; + protected $fontFile = '/fonts/OpenSans-Regular.ttf'; + protected $fontName = 'OpenSans, sans-serif'; + protected $generated_initials = 'JD'; + protected $preferBold = false; /** * Language eg.en zh-CN @@ -313,6 +314,19 @@ public function keepCase( $keepCase = true ) { return $this; } + /** + * Set if should allow (or remove) special characters + * + * @param bool $allowSpecialCharacters + * + * @return $this + */ + public function allowSpecialCharacters( $allowSpecialCharacters = true ) { + $this->allowSpecialCharacters = (bool) $allowSpecialCharacters; + + return $this; + } + /** * Set the font size in percentage * (0.1 = 10%). @@ -337,7 +351,9 @@ public function fontSize( $size = 0.5 ) { public function generate( $name = null ) { if ( $name !== null ) { $this->name = $name; - $this->generated_initials = $this->initials_generator->keepCase( $this->getKeepCase() )->generate( $name ); + $this->generated_initials = $this->initials_generator->keepCase( $this->getKeepCase() ) + ->allowSpecialCharacters( $this->getAllowSpecialCharacters() ) + ->generate( $name ); } return $this->makeAvatar( $this->image ); @@ -474,6 +490,15 @@ public function getKeepCase() { return $this->keepCase; } + /** + * Will return the allowSpecialCharacters parameter. + * + * @return boolean + */ + public function getAllowSpecialCharacters() { + return $this->allowSpecialCharacters; + } + /** * Will return the autofont parameter. *