1
I’m generating an image, which is basically a simple text.
Only the text gets the "buggy" accents, all incorrect, even if I set the encoding to utf-8.
Here’s the code:
<?php
header('Content-Type: image/png; charset=utf-8');
draw("Olá, como vai você?");
function draw($text){
$imagem = imagecreate(700, 30);
$fundo = imagecolorallocate($imagem, 241, 243, 240);
$color = imagecolorallocate($imagem, 200, 30, 30);
imagestring($imagem, 5, 0, 0, $text, $color);
imagepng($imagem);
imagedestroy($imagem);
}
?>
This is just a "abridged version" of the code I want to do. It involves more than a single sentence... The code is just for example of my problem.
The draw()
it runs only once. What varies is only the text...
I tried this way but it appears "The image contains errors and cannot be displayed." :/
– Silva97
Copied the source
arial.ttf
in the script folder? @Superbomber– Guilherme Nascimento
Yes I copied, I took the source of Windows and server is Linux... Could be this?
– Silva97
@Superbomber removes the
header('Content-Type: image/png');
see the error that occurs and let me know.– Guilherme Nascimento
Our I hadn’t thought of it...rsrs here: Warning: imagettftext() [Function.imagettftext]: Could not find/open font in /home/a4071498/public_html/index.php on line 39 ... But I raised the source, see: http://prntscr.com/7q1z34
– Silva97
@Superbomber then it was my mistake, put the following absolute path. I will edit the script in the reply and you copy. Only 1 min
– Guilherme Nascimento
@Superbomber so it was my mistake, I’ve already edited the answer, now it points the whole way.
– Guilherme Nascimento
Another error is now occurring: Warning: imagettftext() [Function.imagettftext]: Could not read font in /home/a4071498/public_html/index.php on line 40 ... Apparently he couldn’t read the source, maybe because it’s for Windows, I don’t know if it makes a difference... But if you do, you know where to download a font for Linux?
– Silva97
But the function
imagettftext
is to load ttf fonts anyway, this is weird. I’ll try it on my Debian and let you know– Guilherme Nascimento
@Superbomber Managed to find the problem?
– Guilherme Nascimento
Unfortunately not... But don’t worry, I decided to use phrases without accents. Thank you very much. :)
– Silva97
Hope not give up rs, I will test here, one minute @Superbomber
– Guilherme Nascimento
Let’s go continue this discussion in chat. @Superbomber
– Guilherme Nascimento
Okay, I’m already logged in to the chat.
– Silva97
@Superbomber out of chat? See the message?
– Guilherme Nascimento
@Superbomber maybe this script using
putenv
help you http://answall.com/a/87967/3635– Guilherme Nascimento