Reputation: 28850
Finally I had to recompile PHP with --enable-gd-jis-conv
.
However the text display is wrong, in Japanese.
$text = '夏の天気';
$fontfile = '/usr/share/fonts/japanese/TrueType/sazanami-mincho.ttf';
return imagettftext ($image, $size, $angle, $x, $y, $color, $fontfile, $text);
But different kanji (Japanese characters) are displayed instead (very different, looks like Chinese).
Could it be an encoding issue?
Using PHP 5.3.3 on RHEL 5.4.
Upvotes: 0
Views: 1958
Reputation: 11
imagettftext($this->im, 58, 0, 50, 100, $text_color, $font, mb_convert_encoding('佳人', 'UTF8', 'UTF-8'));
This worked for me. Seems to work accross a few different Japanese fonts.
Upvotes: 0
Reputation: 28850
I had to run this to get it to work
$text = mb_convert_encoding('夏の天気', "SJIS", 'UTF-8');
Upvotes: 1
Reputation: 4488
Well, japanese as a multibyte encoded language has quite a few quirks. First of all, be sure that your server has the mbstring module installed.
Second, to reduce the chances of possible breakage midway, try to keep all encodings in your site/project consistent: site views and source files should ideally be written with the same encoding.
Specifically for your problem, you might want to try using the following functions:
mb_http_input
http://www.php.net/manual/en/function.mb-http-input.php
This one will make sure your HTTP input is correctly encoded (ie. form data).
mb_ internal_ encoding
http://www.php.net/manual/en/function.mb-internal-encoding.php
Sets the internal encoding used by PHP.
mb_regex_encoding
http://www.php.net/manual/en/function.mb-regex-encoding.php
Sets the encoding used by PHP for regexes.
mb_convert_encoding
http://www.php.net/manual/en/function.mb-convert-encoding.php
For String conversion.
mb_convert_variables
http://www.php.net/manual/en/function.mb-convert-variables.php
Converts encodings of a whole batch of strings/arrays.
Edit: besides, from the name of the module, you might want to try feeding JIS encoded data to the function.
Upvotes: 2