Re: Re: imagettftext and utf-8 (swedish characters)
| From: | David Sveningsson | Date: | Fri, 29 Feb 2008 23:26:44 +0000 |
| Subject: | Re: Re: imagettftext and utf-8 (swedish characters) | ||
| References: | 1 2 3 4 5 6 7 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-270786@lists.php.net to get a copy of this message | ||
Jochem Maas skrev:
I guess I skimmed somewhat too ... but I based my assumption on the following from the OPs post: /index.php/slides/upload: $title = htmlentities($_POST['title'], ENT_COMPAT, 'UTF-8'); $image = '/index.php/slides/preview?title='.urlencode($title).'&content='.urlencode($_POST['content']); so the script handle the form submission looks to be generating a url used as the src of an img. Yes, the script generates an url to the script that renders the image. $image is later used in an img-tag. Maybe there is another way to solve this but this was the only thing I could think of.I have noted that if I use numerical html entities for åäö (Å for instance) I can see the characters correctly. I guess that would mean the string passed is *not* correct utf-8. Here is the current source: $title = htmlentities( stripslashes($_POST['title']), ENT_NOQUOTES, "utf-8" ); $content = htmlentities( stripslashes($_POST['content']), ENT_NOQUOTES, "utf-8" ); $image = '/index.php/slides/preview?title='.urlencode($title).'&content='.urlencode($content)."&align=$align"; ... $title = html_entity_decode(get('title'), ENT_NOQUOTES, 'UTF-8'); $im = imagecreatetruecolor(800, 600); $black = imagecolorallocate($im, 0, 0, 0); $white = imagecolorallocate($im, 255, 255, 255);
// $font = "/usr/share/fonts/corefonts/arial.ttf";$font = "/usr/share/fonts/ttf-bitstream-vera/Vera.ttf"; $title_size = 42; imagefilledrectangle($im, 0, 0, 800, 600, $black); $this->_string_centered($im, 70, $title_size, $font, $white, $title); header("Content-Type: image/png"); imagepng($im);
If anyone want to see the site or complete source I could send the url off-list. //*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.Georgia.tff should cover swedish characters - atleast it does on my system (MPB) ... my little test script in my other post on this thread works for me ... I have no idea if one should/could expect variations of supported characters in a TTF font file depending on the system your on (my guess would be you could rely on all systems that have said TTF file to support the same chars - I assume that although it may be compiled diffferently for different platforms the source font definition is going to be the same) All fonts I have tried works in other applications with utf-8. (I run lamp on my own workstation at the moment).Thus, it leads me back to my previous guess that the font he chose(georgia.ttf) doesn't have Swedish characters in the set. With that, I'm not sure, though, because I don't have the Georgia font pack on here, so it'll have to stay as a guess for now.