File tree Expand file tree Collapse file tree 3 files changed +40
-0
lines changed
Expand file tree Collapse file tree 3 files changed +40
-0
lines changed Original file line number Diff line number Diff line change 66use Intervention \Image \ImageManager ;
77use LasseRafn \InitialAvatarGenerator \Translator \Base ;
88use LasseRafn \InitialAvatarGenerator \Translator \En ;
9+ use LasseRafn \InitialAvatarGenerator \Translator \Tr ;
910use LasseRafn \InitialAvatarGenerator \Translator \ZhCN ;
1011use LasseRafn \Initials \Initials ;
1112use LasseRafn \StringScript ;
@@ -61,6 +62,7 @@ class InitialAvatar
6162 */
6263 protected $ translatorMap = [
6364 'en ' => En::class,
65+ 'tr ' => Tr::class,
6466 'zh-CN ' => ZhCN::class,
6567 ];
6668
@@ -794,6 +796,11 @@ protected function getFontByScript()
794796 return __DIR__ .'/fonts/script/Noto-Tibetan-Regular.ttf ' ;
795797 }
796798
799+ // Turkish
800+ if (StringScript::isLatin ($ this ->getInitials ())) {
801+ return __DIR__ .'/fonts/NotoSans-Regular.ttf ' ;
802+ }
803+
797804 // Chinese & Japanese
798805 if (StringScript::isJapanese ($ this ->getInitials ()) || StringScript::isChinese ($ this ->getInitials ())) {
799806 return __DIR__ .'/fonts/script/Noto-CJKJP-Regular.otf ' ;
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace LasseRafn \InitialAvatarGenerator \Translator ;
4+
5+ class Tr implements Base
6+ {
7+ /**
8+ * @inheritdoc
9+ */
10+ public function translate ($ words )
11+ {
12+ return $ words ;
13+ }
14+
15+ /**
16+ * @inheritdoc
17+ */
18+ public function getSourceLanguage ()
19+ {
20+ return 'tr ' ;
21+ }
22+ }
Original file line number Diff line number Diff line change @@ -93,6 +93,17 @@ public function can_detect_and_use_script_Tibetan()
9393 $ this ->assertTrue ($ image ->stream ()->isReadable ());
9494 }
9595
96+ /** @test */
97+ public function can_detect_and_use_script_Turkish ()
98+ {
99+ $ avatar = new InitialAvatar ();
100+
101+ $ image = $ avatar ->autoFont ()->generate ('şçğüöı ' );
102+
103+ $ this ->assertEquals ('Intervention\Image\Image ' , get_class ($ image ));
104+ $ this ->assertTrue ($ image ->stream ()->isReadable ());
105+ }
106+
96107 /** @test */
97108 public function can_detect_and_use_script_Uncommon ()
98109 {
You can’t perform that action at this time.
0 commit comments