imagettftext and utf-8 (swedish characters)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi, I've ran into some problems when outputing text to an image using imagettftext. I cannot get swedish characters to work, I just get a square. I've tried different fonts which I know has those characters (bitstream vera, arial, times new roman, etc). What am I doing wrong?

I know I must pass utf-8 encoded text and I belive I do but I don't know how to check it.

HTML form code:
(html document uses utf-8 as charset and apache is set to use utf-8 too)

<form action="/index.php/slides/upload" method="post" accept-charset="utf-8">
<input type="text" id="title" name="title" size="70" value="" />
</form>

/index.php/slides/upload:

$title = htmlentities($_POST['title'], ENT_COMPAT, 'UTF-8');
$image = '/index.php/slides/preview?title='.urlencode($title).'&content='.urlencode($_POST['content']);

/index.php/slides/preview:

  function preview(){
    $title = html_entity_decode($_GET['title'], ENT_COMPAT, 'UTF-8');
    //$title = $_GET['title'];

    ///@note Hardcoded resolution
    $im  = imagecreatetruecolor(800, 600);
    $black  = imagecolorallocate($im, 0, 0, 0);
    $white  = imagecolorallocate($im, 255, 255, 255);
    $font = "/usr/share/fonts/corefonts/georgia.ttf";

    $title_size = 32;

    imagefilledrectangle($im, 0, 0, 800, 600, $black);

    imagettftext( $im, $title_size, 0, 50, 50, $white, $font, $title );
	
    header("Content-Type: image/png");
    imagepng($im);
    exit();
  }

--


//*David Sveningsson [eXt]*

Freelance coder | Game Development Student
http://sidvind.com

Thou shalt make thy program's purpose and structure clear to thy fellow man by using the One True Brace Style, even if thou likest it not, for thy creativity is better used in solving problems than in creating beautiful new impediments to understanding.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux