David Sveningsson schreef:
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();
  }

have you tried a test script (file encoded as UTF8) where you hardcode the
title string and see if that also outputs 'squares' ... at least that way
you can be sure whether the problem is in some kind of encoding mush that occurs
during the title's roundtrip of server -> browser -> server OR whether the 
problem is
actually to do with imagetfftext.




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

Reply via email to