Jump to content

Code Help


tjstalcup

Recommended Posts

This returns nothing, what is wrong with the function:

[code]
<?php
header("Content-type: image/png");
$shell = imagecreatefromjpeg("imgs/shells/".$shell_image."");
$red = imagecolorallocate($shell,220,50,50);
$fontbold = "font/HU521BTB.ttf";

function kearning($text, $fontsize, $font, $nxpos, $kearn, $ypos, $fontcolor) {
for($i=0;$i<strlen($text);$i++){
      // Get single character
  $value=substr($text,$i,1);
  if($pval){ // check for existing previous character
      list($lx,$ly,$rx,$ry) = imagettfbbox($fontsize,0,$font,$pval);
      $nxpos+=$rx+$kearn;
  }else{
$nxpos = $nxpos;
  }
      // Add the letter to the image
  imagettftext($shell, $fontsize, 0, $nxpos, $ypos, $fontcolor, $font, $value);
  $pval=$value; // save current character for next loop
}

}

kearning("Testing", 13, $fontbold, 256, 1.25, 30, $red);

imageline($shell,0,0,0,288,$blue);//left
imageline($shell,0,0,494,0,$blue);//top
imageline($shell,0,287,494,287,$blue);//bottom
imageline($shell,493,0,493,288,$blue);//right
imagepng($shell);
imagepsfreefont($font);
imagedestroy($shell);
?>
[/code]
Link to comment
https://forums.phpfreaks.com/topic/34775-code-help/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.