@@ -11,6 +11,7 @@ class InitialAvatar
1111
1212 private $ parameter_cacheTime = 0 ;
1313 private $ parameter_length = 2 ;
14+ private $ parameter_fontSize = 0.5 ;
1415 private $ parameter_initials = 'JD ' ;
1516 private $ parameter_name = 'John Doe ' ;
1617 private $ parameter_size = 48 ;
@@ -74,6 +75,13 @@ public function cache( int $minutes = 60 ): self
7475 return $ this ;
7576 }
7677
78+ public function fontSize ( float $ size = 0.5 ): self
79+ {
80+ $ this ->parameter_fontSize = (float ) $ size ;
81+
82+ return $ this ;
83+ }
84+
7785 /**
7886 * Generate the image
7987 *
@@ -88,18 +96,19 @@ public function generate( $name = null ): Image
8896 $ this ->parameter_initials = $ this ->generateInitials ( $ this ->parameter_name );
8997 }
9098
91- $ fontFile = $ this ->parameter_fontFile ;
9299 $ size = $ this ->parameter_size ;
93- $ color = $ this ->parameter_fontColor ;
94100 $ bgColor = $ this ->parameter_bgColor ;
95101 $ name = $ this ->parameter_initials ;
102+ $ fontFile = $ this ->parameter_fontFile ;
103+ $ color = $ this ->parameter_fontColor ;
104+ $ fontSize = $ this ->parameter_fontSize ;
96105
97- $ img = $ this ->image ->cache ( function ( ImageCache $ image ) use ( $ size , $ bgColor , $ color , $ fontFile , $ name )
106+ $ img = $ this ->image ->cache ( function ( ImageCache $ image ) use ( $ size , $ bgColor , $ color , $ fontFile , $ name, $ fontSize )
98107 {
99- $ image ->canvas ( $ size , $ size , $ bgColor )->text ( $ name , $ size / 2 , $ size / 2 , function ( $ font ) use ( $ size , $ color , $ fontFile )
108+ $ image ->canvas ( $ size , $ size , $ bgColor )->text ( $ name , $ size / 2 , $ size / 2 , function ( $ font ) use ( $ size , $ color , $ fontFile, $ fontSize )
100109 {
101110 $ font ->file ( __DIR__ . $ fontFile );
102- $ font ->size ( $ size / 2 );
111+ $ font ->size ( $ size * $ fontSize );
103112 $ font ->color ( $ color );
104113 $ font ->align ( 'center ' );
105114 $ font ->valign ( 'center ' );
0 commit comments