Jump to content

italics ttf img with php help please


sweettea

Recommended Posts

I am in need of assistance with this form I am trying to create at

www.southshoreenterprises.com/boattest.php

 

the external php file is below.

I cannot seem to make the italics effect work.

Thank you.

 

<?PHP

 

function imagettftextoutline(&$im,$size,$angle,$x,$y,&$col,

&$outlinecol,$fontfile,$text,$width) {

// For every X pixel to the left and the right

for ($xc=$x-abs($width);$xc<=$x+abs($width);$xc++) {

// For every Y pixel to the top and the bottom

for ($yc=$y-abs($width);$yc<=$y+abs($width);$yc++) {

// Draw the text in the outline color

$text1 = imagettftext($im,$size,$angle,$xc,$yc,$outlinecol,$fontfile,$text);

}

}

// Draw the main text

$text2 = imagettftext($im,$size,$angle,$x,$y,$col,$fontfile,$text);

}

 

function ImageColorAllocateFromHex ($img, $hexstr)

{

$int = hexdec($hexstr);

 

return ImageColorAllocate ($img,

0xFF & ($int >> 0x10),

0xFF & ($int >> 0x8),

0xFF & $int);

}

 

header("Content-type: image/png");

$tcolor = '#'.$_GET['textColor'];

$bcolor = '#'.$_GET['boatColor'];

$t2color= '#'.$_GET['text2Color'];

$ecolor = '#'.$_GET['effectColor'];

 

$i = imagecreatetruecolor(500,170);

 

 

 

$fontcolour = imagecolorallocatefromhex($i,$tcolor);

$font2colour = imagecolorallocatefromhex($i, $t2color);

$bg = imagecolorallocatefromhex($i,$bcolor);

$ec = imagecolorallocatefromhex($i,$ecolor);

 

 

if($bcolor == '#000000') $bg = imagecolorallocate($i, 0, 0, 0);

if($tcolor == '#000000') $fontcolour = imagecolorallocate($i, 1, 0, 0);

if($t2color== '#000000') $font2colour = imagecolorallocate($i, 1, 0, 0);

if($ecolor == '#000000') $ec = imagecolorallocate($i, 1, 0, 0);

 

if($_GET['fontFileName'] == "") {$fontfile = "arial.ttf";} else {$fontfile = $_GET['fontFileName'];}

//echo "fonts/$fontfile";

$box = imagettfbbox(40, 0, "fonts/".$fontfile, $_GET['text']);

$ax = ceil((500 - $box[2]) / 2);

$ay = ceil((170 - $box[3]) / 2);

$box2 = imagettfbbox(20, 0, "fonts/arial.ttf", $_GET['text2']);

$bx = ceil((500 - $box2[2]) / 2);

$by = ceil((170 - $box2[3]) / 2) + 50;

 

//image, size, angle, x, y, color, font, text

imagefill($i, 0, 0, $bg);

if ($_GET['shadowFlag'] == 1) imagettftext($i, 40, 0, $ax+3, $ay+3, $ec, "fonts/".$fontfile, $_GET['text']);

if ($_GET['strokeFlag'] == 1) imagettftextoutline($i, 40, 0, $ax, $ay, $fontcolour, $ec, "fonts/".$fontfile, $_GET['text'], 1);

if ($_GET['italicFlag'] == 1) imagettftext($ax, $ay, $angle=90, "fonts/".$fontfile, $_GET['text']);

else imagettftext($i, 40, 0, $ax, $ay, $fontcolour, "fonts/".$fontfile, $_GET['text']);

imagettftext($i, 20, 0, $bx, $by, $font2colour, "fonts/arial.ttf", $_GET['text2']);

imagepng($i);

?>

Link to comment
https://forums.phpfreaks.com/topic/112500-italics-ttf-img-with-php-help-please/
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.