Log in

View Full Version : Title to image convert problem !!!



winpeace
10-20-2008, 02:44 PM
When I convert title to image site character broken.My language turkish(ISO-8859-9).Problem characters are ş-ı-ğ.The font is turkish.How am I solved this problem?


system_function_title.php

<?


header("Content-type: image/png");
header("Content-Disposition: inline; filename=" . $file);
header("Content-Type: text/xml; charset =ISO-8859-9");



// create the test to get width first ...
$test = imagecreate($image_width, $image_height);
$back = imagecolorallocate($test, $back_color[0] , $back_color[1] , $back_color[2] );
$front = imagecolorallocate($test, $front_color[0] , $front_color[1] , $front_color[2] );
$image_text = imagettftext($test, $font_size, 0, $position_left, $position_top, $front, $font_file, $text);
$image_width = $image_text[2] - $image_text[0] + 20;
imagedestroy($test);




// now this is the serious image ...
$im = imagecreate($image_width + 2 * $position_left, $image_height);
$back = imagecolorallocate($im, $back_color[0] , $back_color[1] , $back_color[2] );
$front = imagecolorallocate($im, $front_color[0] , $front_color[1] , $front_color[2] );

imagefilledrectangle($im, 0, 0, $image_width, $image_height, $back );
imagecolortransparent($im, $back);

$image_text = imagettftext($im, $font_size, 0, $position_left, $position_top, $front, $font_file, $text);
$image_width = $image_text[2] - $image_text[0];

imagepng($im);
imagedestroy($im);



?>


File

<?

include("setting.php");

$title = str_replace("\'", "'", $title);

$file = "$title.png";
$text = html_entity_decode($title, ENT_QUOTES);
$back_color = array(255, 255, 255); // (red, green, blue)
$front_color = array(193 , 0 , 0); // (red, green, blue)

$font_file = 'files/font/1.ttf';
$font_size = 18;

$image_width = (strlen($text)) * ($font_size - 1) + 20;
$image_height = 30;


$position_left = 0;
$position_top = 20;

include("system_function_title.php");



?>

Jesdisciple
10-20-2008, 07:04 PM
Here's how you can tell PHP about your encoding: mb_internal_encoding (http://www.php.net/manual/en/function.mb-internal-encoding.php)('ISO 8859-9 (http://en.wikipedia.org/wiki/ISO_8859-9)')

See also http://en.wikipedia.org/wiki/Help:Turkish_characters for an alternative solution.