No exxageration, I'm using this php code to render text as an image for my online/offline API and I can't work out how to change the font?
<?PHP
//parser in spaces
$count = 1;
$string = $_GET['string'];
$parser = '';
while ($count < strlen($_GET['string'])){
if(substr($string, $count, 1) == '_'){
$parser = $parser . ' ';
}
else{
$parser = $parser . (substr($string, $count, 1));
}
$count ++;
}
// Set font size
$font_size = 2;
// Create image width dependant on width of the string
$width = imagefontwidth($font_size)*strlen($string);
// Set height to that of the font
$height = imagefontheight($font_size);
// Create the image pallette
$img = imagecreate($width,$height);
// Grey background
$bg = imagecolorallocate($img, 222, 223, 223);
// Black font color
$color = imagecolorallocate($img, 0, 0, 0);
// Length of the string
$len = strlen($string);
// Y-coordinate of character, X changes, Y is static
$ypos = 0;
// Loop through the string
for($i=0;$i<$len;$i++){
// Position of the character horizontally
$xpos = $i * imagefontwidth($font_size);
// Draw character
imagechar($img, $font_size, $xpos, $ypos, $string, $color);
// Remove character from string
$string = substr($string, 1);
}
// Return the image
header("Content-Type: image/gif");
imagegif($img);
// Remove image
imagedestroy($img);
?>The Scratch font is generally agreed to be Trebuchet MS so it would be great to somehow get that font working on this... Any help would be appreciated as I don't know much about text rendering
You can test it
[img]http://www.blocks.scratchr.org/API.php?action=text&string=your_text[/img]
Offline
I'm guessing this might be helpful? I don't know much about php
Offline
Maybe the font needs to be installed on your computer?
Offline