0

I'm using the following code to generate a text-based image. Everything works fine except that letters "a" and "A" appear as å and Å respectively. Why?

Everything appears fine but a / A.

    header('Content-Type: image/png');

// Create the image
$im = imagecreatetruecolor(400, 30);

// Create some colors
$white = imagecolorallocate($im, 255, 255, 255);
$grey = imagecolorallocate($im, 128, 128, 128);
$black = imagecolorallocate($im, 0, 0, 0);
imagefilledrectangle($im, 0, 0, 399, 29, $white);

// The text to draw
//$text = @$_GET['text'];
$text = "qwertyuiopASDFGHJKLasdfghjklzxcvbnm";

// Replace path by your own font path
$font = 'arial.ttf';

// Add some shadow to the text
//imagettftext($im, 12, 0, 11, 21, $grey, $font, $text);

// Add the text
imagettftext($im, 12, 0, 10, 20, $black, $font, $text);

// Using imagepng() results in clearer text compared with imagejpeg()
imagepng($im);
imagedestroy($im);

Thanks! =)

edit: Snapshot of img: enter image description here

edit2: Does this conclude anything? http://en.wikipedia.org/wiki/%C3%85#On_computers

  • That sounds strange. Can you show a screen shot of such an image? – Pekka Aug 12 '12 at 13:00
  • It really sounds strange. And I'd say it is hard to say unless one could use the system you sit in front of and debug the issue. Also the dead code you have in there is a smell in my eyes that yourself is part of the problem and not it's solution. – hakre Aug 12 '12 at 13:01
  • There's the image. And, the dead code wasn't supposed to be there. Regardless, the problem persists. – Carlos Infoster Aug 12 '12 at 13:04
  • Pass it a unicode string `utf8_encode($text)` – Burhan Khalid Aug 12 '12 at 13:14
  • You're 1000000% sure your source material is an `A`? If yes, then this really is super weird. Can you use an alternative font and see whether the problem persists? – Pekka Aug 12 '12 at 15:45
  • I am and I did try multiple fonts. Isn't it strange? Like an internal bug?! I'm using XAMPP on Windows 7 Home Premium (i7 Processor). – Carlos Infoster Aug 12 '12 at 15:59

1 Answers1

0

ISSUE RESOLVED:

The font helonia.ttf has something weird. Idk what but it did.

I tried arial.ttd and issue was resolved!

Thanks to all who helped!