function writeText($image, $fontsize, $xpos, $ypos, $color, $font, $text, $align, $shadow_color) { // Get the font $font = getFont($font); // Get the color $color = setColor($image, $color); // Convert text for display $text = utf8_to_nce($text); // Correct alignment if ($align != 'left') { $xpos = textAlignment($font, $fontsize, $text, $xpos, $align); } // Create the pseudo-shadow if (!empty($shadow_color)) { shadowText($image, $fontsize, $xpos, $ypos, $font, $text, $shadow_color); } // Write the text @imageTTFText($image, $fontsize, 0, $xpos, $ypos, $color, $font, $text) or debugMode(__LINE__, $php_errormsg); }
} foreach ($commands as $c) { if ($c["command"] == "poly") { $color = getColor($id, $c["color"], $im); imagefilledpolygon($im, $c["points"], count($c["points"]) / 2, $color); } elseif ($c["command"] == "asset") { $asset = imagecreatefrompng($c["asset"]); imagecopy($im, $asset, $c["points"][0], $c["points"][1], 0, 0, $c["points"][2], $c["points"][3]); } elseif ($c["command"] == "img") { $imgsrc = getContent($id, $c["asset"]); $img = imagecreatefrompng("{$imgsrc}"); $size = getimagesize("{$imgsrc}"); imagecopyresampled($im, $img, $c["points"][0], $c["points"][1], 0, 0, $c["points"][2], $c["points"][3], $size[0], $size[1]); } elseif ($c["command"] == "text") { $content = getContent($id, $c["content"]); $font = getFont($c["font"]); if ($c["align"] == "r") { $r = imagefttext($im, $c["size"], 0, 700, 0, $white, $font, $content); $c["points"][0] -= $r[2] - $r[0]; } if ($c["shadow"] > 0) { imagefttext($im, $c["size"], 0, $c["points"][0] + $c["shadow"], $c["points"][1] + $c["shadow"], $black, $font, $content); } imagefttext($im, $c["size"], 0, $c["points"][0], $c["points"][1], $white, $font, $content); } } header('Content-Type: image/png'); imagealphablending($im, false); imagesavealpha($im, true); imagepng($im); imagedestroy($im);
function opt($v, $def) { if ($v == 'contentFontFull' || $v == 'headerFontFull') { $v = str_replace('Full', '', $v); return getFont(opt($v, ''), 'url', $v); } elseif (get_option($v) == '') { return $def; } else { return get_option($v); } }
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Document</title> <link rel="stylesheet" href="assets/style.css"> <link href='https://fonts.googleapis.com/css?family=<?php echo getFont(); ?> 'rel='stylesheet' type='text/css'> <style> .copy { font-family: <?php echo getFont(); ?> } </style> </head> <body>
function load_font_variants() { echo '{"status":"OK", "variants":' . json_encode(getFont($_POST['font'], 'variants')) . '}'; die; }