@@ -24,21 +24,22 @@ class InitialAvatar
24
24
/** @var Initials */
25
25
protected $ initials_generator ;
26
26
27
- protected $ driver = 'gd ' ; // imagick or gd
28
- protected $ fontSize = 0.5 ;
29
- protected $ name = 'John Doe ' ;
30
- protected $ width = 48 ;
31
- protected $ height = 48 ;
32
- protected $ bgColor = '#f0e9e9 ' ;
33
- protected $ fontColor = '#8b5d5d ' ;
34
- protected $ rounded = false ;
35
- protected $ smooth = false ;
36
- protected $ autofont = false ;
37
- protected $ keepCase = false ;
38
- protected $ fontFile = '/fonts/OpenSans-Regular.ttf ' ;
39
- protected $ fontName = 'OpenSans, sans-serif ' ;
40
- protected $ generated_initials = 'JD ' ;
41
- protected $ preferBold = false ;
27
+ protected $ driver = 'gd ' ; // imagick or gd
28
+ protected $ fontSize = 0.5 ;
29
+ protected $ name = 'John Doe ' ;
30
+ protected $ width = 48 ;
31
+ protected $ height = 48 ;
32
+ protected $ bgColor = '#f0e9e9 ' ;
33
+ protected $ fontColor = '#8b5d5d ' ;
34
+ protected $ rounded = false ;
35
+ protected $ smooth = false ;
36
+ protected $ autofont = false ;
37
+ protected $ keepCase = false ;
38
+ protected $ allowSpecialCharacters = true ;
39
+ protected $ fontFile = '/fonts/OpenSans-Regular.ttf ' ;
40
+ protected $ fontName = 'OpenSans, sans-serif ' ;
41
+ protected $ generated_initials = 'JD ' ;
42
+ protected $ preferBold = false ;
42
43
43
44
/**
44
45
* Language eg.en zh-CN
@@ -313,6 +314,19 @@ public function keepCase( $keepCase = true ) {
313
314
return $ this ;
314
315
}
315
316
317
+ /**
318
+ * Set if should allow (or remove) special characters
319
+ *
320
+ * @param bool $allowSpecialCharacters
321
+ *
322
+ * @return $this
323
+ */
324
+ public function allowSpecialCharacters ( $ allowSpecialCharacters = true ) {
325
+ $ this ->allowSpecialCharacters = (bool ) $ allowSpecialCharacters ;
326
+
327
+ return $ this ;
328
+ }
329
+
316
330
/**
317
331
* Set the font size in percentage
318
332
* (0.1 = 10%).
@@ -337,7 +351,9 @@ public function fontSize( $size = 0.5 ) {
337
351
public function generate ( $ name = null ) {
338
352
if ( $ name !== null ) {
339
353
$ this ->name = $ name ;
340
- $ this ->generated_initials = $ this ->initials_generator ->keepCase ( $ this ->getKeepCase () )->generate ( $ name );
354
+ $ this ->generated_initials = $ this ->initials_generator ->keepCase ( $ this ->getKeepCase () )
355
+ ->allowSpecialCharacters ( $ this ->getAllowSpecialCharacters () )
356
+ ->generate ( $ name );
341
357
}
342
358
343
359
return $ this ->makeAvatar ( $ this ->image );
@@ -474,6 +490,15 @@ public function getKeepCase() {
474
490
return $ this ->keepCase ;
475
491
}
476
492
493
+ /**
494
+ * Will return the allowSpecialCharacters parameter.
495
+ *
496
+ * @return boolean
497
+ */
498
+ public function getAllowSpecialCharacters () {
499
+ return $ this ->allowSpecialCharacters ;
500
+ }
501
+
477
502
/**
478
503
* Will return the autofont parameter.
479
504
*
0 commit comments