Nolongerused3921 Posted December 26, 2007 Share Posted December 26, 2007 Basically I've created a database with Japanese in it, under UTF-8 and have gotten it into PHP properly - I am able to print_r the table and it shows the Japanese properly, however I can not get GD to print it - even using a hiragana (Its Hiragana, not kata or kanji) ttf font and imagettftext... Has anyone worked with GD + foreign languages before? Is there a native PHP font that I can use, rather than a font I found online? If not, or even if so - whats the best way to get Japanese into an image, using GD? I plan on using Hiragana, Katakana, AND Kanji at some point (Just hiragana for now), so it'd be nice to have a native PHP UTF-8 Japanese font available, rather than hunting all over for new fonts and all that. Quote Link to comment https://forums.phpfreaks.com/topic/83276-printing-japanese-in-gd/ Share on other sites More sharing options...
Nolongerused3921 Posted December 27, 2007 Author Share Posted December 27, 2007 Anyone? Quote Link to comment https://forums.phpfreaks.com/topic/83276-printing-japanese-in-gd/#findComment-424330 Share on other sites More sharing options...
helraizer Posted December 27, 2007 Share Posted December 27, 2007 Could you please show us your code? Sam Quote Link to comment https://forums.phpfreaks.com/topic/83276-printing-japanese-in-gd/#findComment-424333 Share on other sites More sharing options...
Nolongerused3921 Posted December 27, 2007 Author Share Posted December 27, 2007 90% of this is in the database, the other 10% is just getting the information from the database, and putting it into an array. I had experimented with some code taken from php.net (For GD + ttf fonts), however thats unimportant. Quote Link to comment https://forums.phpfreaks.com/topic/83276-printing-japanese-in-gd/#findComment-424335 Share on other sites More sharing options...
marcus Posted December 27, 2007 Share Posted December 27, 2007 So you've tried loading your TrueTypeFont file into the document? Well it's most likely going to be hard to accomplish because the characters are not of use of the English alphabet. Quote Link to comment https://forums.phpfreaks.com/topic/83276-printing-japanese-in-gd/#findComment-424338 Share on other sites More sharing options...
Nolongerused3921 Posted December 27, 2007 Author Share Posted December 27, 2007 Thats what I'm asking, does PHP/GD have (Access to) a UTF-8 font? Quote Link to comment https://forums.phpfreaks.com/topic/83276-printing-japanese-in-gd/#findComment-424343 Share on other sites More sharing options...
helraizer Posted December 27, 2007 Share Posted December 27, 2007 Thats what I'm asking, does PHP/GD have (Access to) a UTF-8 font? In short, yes. I'll try and give you an example. If the font you have (hiragana) is in ttf format, then you must have it in the same font that the code is in. <?php $font = "HIRAGANA.ttf"; $image = ImageCreate(300,100); $black = ImageColorAllocate($image, 0, 0, 0); $white = ImageColorAllocate($image, 255,255,255); ImageFill($image, 0, 0, $black); Imagettftext($image, 12, 0, 20,30,$white,$font,"Your text here"); header("Content-Type: image/gif"); Imagegif($image); Imagegif($image, "image.gif"); imagedestroy($image); ?> That works. That code, with different image dimensions produces this Quote Link to comment https://forums.phpfreaks.com/topic/83276-printing-japanese-in-gd/#findComment-424354 Share on other sites More sharing options...
Nolongerused3921 Posted December 29, 2007 Author Share Posted December 29, 2007 Sadly that won't work, as the font isn't unicode (And thus won't work seeing as Japanese isn't a Romance language). Basically the text you just typed doesn't make sense, it comes out to being: u - chi t - e t#2 - dji (I believe) e - u x - ...Well, you get the idea Quote Link to comment https://forums.phpfreaks.com/topic/83276-printing-japanese-in-gd/#findComment-425185 Share on other sites More sharing options...
helraizer Posted December 29, 2007 Share Posted December 29, 2007 Sadly that won't work, as the font isn't unicode (And thus won't work seeing as Japanese isn't a Romance language). Basically the text you just typed doesn't make sense, it comes out to being: u - chi t - e t#2 - dji (I believe) e - u x - ...Well, you get the idea Hmm.. true, but what I typed in there was Your Text Here, which came up as complete nonsense in Japanese. The Hiragana font is for Japanese so each letter translates to the japanese meaning, thus you have to write it accordingly. Sam Quote Link to comment https://forums.phpfreaks.com/topic/83276-printing-japanese-in-gd/#findComment-425217 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.