@@ -937,25 +937,25 @@ public function writeTextAndGetBoundingBox(string $string, string $fontPath, int
937937 * @param $font
938938 * @param $text
939939 * @param int $spacing
940- * @return array|false
940+ * @return array
941941 */
942- private function imagettftextWithSpacing ($ image , $ size , $ angle , $ x , $ y , $ color , $ font , $ text , int $ spacing = 0 )
942+ private function imagettftextWithSpacing ($ image , float $ size , float $ angle , float $ x , float $ y , int $ color , string $ font , string $ text , int $ spacing = 0 )
943943 {
944944 if ($ spacing == 0 )
945945 {
946- return imagettftext ($ image , $ size , $ angle , $ x , $ y , $ color , $ font , $ text );
946+ return \ imagettftext ($ image , $ size , $ angle , $ x , $ y , $ color , $ font , $ text );
947947 }
948948 else
949949 {
950950 $ temp_x = $ x ;
951951 $ temp_y = $ y ;
952- $ posText = false ;
953- for ($ i = 0 ; $ i < strlen ($ text ); $ i ++ )
952+ $ posText = [] ;
953+ for ($ i = 0 ; $ i < \mb_strlen ($ text ); ++ $ i )
954954 {
955- $ posText = imagettftext ($ image , $ size , $ angle , $ temp_x , $ temp_y , $ color , $ font , $ text [$ i ]);
956- $ bbox = imagettfbbox ($ size , 0 , $ font , $ text [$ i ]);
957- $ temp_x += cos (deg2rad ($ angle )) * ($ spacing + ($ bbox [2 ] - $ bbox [0 ]));
958- $ temp_y -= sin (deg2rad ($ angle )) * ($ spacing + ($ bbox [2 ] - $ bbox [0 ]));
955+ $ posText = \ imagettftext ($ image , $ size , $ angle , $ temp_x , $ temp_y , $ color , $ font , $ text [$ i ]);
956+ $ bbox = \ imagettfbbox ($ size , 0 , $ font , $ text [$ i ]);
957+ $ temp_x += \ cos (\ deg2rad ($ angle )) * ($ spacing + ($ bbox [2 ] - $ bbox [0 ]));
958+ $ temp_y -= \ sin (\ deg2rad ($ angle )) * ($ spacing + ($ bbox [2 ] - $ bbox [0 ]));
959959 }
960960 return $ posText ;
961961 }
0 commit comments