{"flag":true,"single":true,"pageTitle":"GD library |Add your own fount for text using imagettftext ||PHP","post":{"id":336,"user_id":"1","slug":"gd-library-add-your-own-fount-for-text-using-imagettftext-php-x5jc","title":"GD library |Add your own fount for text using imagettftext ||PHP","body":"<pre class=\"language-markup\"><code>$image=imagecreatetruecolor(500, 600);\r\nimagefilledrectangle($image, 0, 0, 500, 600,0x02B0B4);\/\/set background color\r\nimagefilledrectangle($image, 10, 10, 200, 200,0x0222B4);\/\/set background color\r\nimagesetthickness( $image, 10 );\r\n$imageWidth=imagesx($image);\r\n$imageHeight=imagesy($image);\r\n$text=\"Rizwan Akhtar Gondal\";\r\n$textLength=strlen($text);\r\n$fontSize= intval($imageWidth\/$textLength);\t\r\n\/\/array imagettftext( resource $image, float $size, float $angle,int $x, int $y, int $color, string $fontfile, string $text); \/\/add ttf font for text on image\r\n$text=imagettftext($image,$fontSize, 0, 0, $fontSize+10,0xFFFFFF, realpath('Sophia.ttf'),$text);\r\nheader('Content-type: image\/png');\r\nimagepng($image);\r\nimagedestroy($image);<\/code><\/pre>","category_id":"1","is_private":"0","created_at":"2026-01-07T11:31:44.000000Z","updated_at":"2026-01-07T11:31:44.000000Z","category":{"id":1,"user_id":"1","name":"PHP","slug":"php-3ius","parent_id":null,"created_at":"2023-03-14T03:58:19.000000Z","updated_at":"2023-03-14T03:58:19.000000Z"},"user":{"id":1,"name":"R GONDAL","email":"rizikmw@gmail.com","email_verified_at":null,"two_factor_confirmed_at":null,"current_team_id":"1","profile_photo_path":null,"created_at":"2023-03-12T10:49:33.000000Z","updated_at":"2025-01-10T12:59:00.000000Z","profile_photo_url":"https:\/\/ui-avatars.com\/api\/?name=R+G&color=7F9CF5&background=EBF4FF"}},"pageDesc":"$image=imagecreatetruecolor(500, 600); imagefilledrectangle($image, 0, 0, 500, 600,0x02B0B4);\/\/set background color imagefilledrectangle($im - GD library |Add your own fount for text using imagettftext ||PHP (Updated: January 7, 2026) - Read more about GD library |Add your own fount for text using imagettftext ||PHP at my programming site [SITE]","categories":[]}