Asked 7 years ago
17 Dec 2016
Views 1455
noob

noob posted

big font with gd library in php

how to apply more font size to text in GD library in Php
i am using imagestring function from GD library , it draw a string horizontally.


header("Content-type: image/jpeg");
$string = "down is up";
$im     = imagecreate(200,200);
$bg = imagecolorallocate($im, 255, 255, 255);
$orange = imagecolorallocate($im, 0, 0, 0);
$px     = (imagesx($im) - 7.5 * strlen($string)) / 2;
imagestring($im, 5, $px, 9, $string, $orange);
 imagepng($im);
imagedestroy($im);


it produce
this max size (5 px ) font what can be generated by imagestring , i want more font size and i found there is no way to do so .

so how can one generate image with heavy font size string in GD library at php ?
shyam

shyam
answered Nov 30 '-1 00:00

use imageloadfont function , to load font with needed size .


$colorwhite = imagecolorallocate($im, 255, 255, 255);
$font = imageloadfont('neededfont.gdf');
imagestring($im, $font, 0, 0, 'Hello', $colorwhite);

or
you can use it with imagechar

$colorwhite = imagecolorallocate($im, 255, 255, 255);
$font = imageloadfont('neededfont.gdf');
$string="hello";
for($i=0;$i<strlen($string);$i++){
   imagechar($im, $font, 0, 0, $string[$i], $colorwhite);
}




where to get .gdf file for font - noob  
Dec 17 '16 04:06
Post Answer