Chinese characters and GD?

Discussion in 'PHP' started by NuPagady, Apr 17, 2006.

  1. #1
    Hi guys,

    I'm trying to write a php+gd+imagettftext script which would support as many languages as possible. Everything seems to be working fine with European languages (German, Lithuanian..), but when I try to use Chinese characters, squares appears instead of Chinese characters (see the attached image).

    Do you know how to successfully output Chinese characters by gd?


    Thanks
    - Paul
     

    Attached Files:

    NuPagady, Apr 17, 2006 IP
  2. digitalpoint

    digitalpoint Overlord of no one Staff

    Messages:
    38,334
    Likes Received:
    2,613
    Best Answers:
    462
    Trophy Points:
    710
    Digital Goods:
    29
    #2
    Are you using a font that has full support for them?
     
    digitalpoint, Apr 17, 2006 IP
  3. misohoni

    misohoni Notable Member

    Messages:
    1,717
    Likes Received:
    32
    Best Answers:
    0
    Trophy Points:
    200
    #3
    I had this problem also. If you are using a DB you need to make sure the characters are set as UTF8- General.

    Also your PHP files may not be encoded as UTF8 so say in DW you can change this via Page Properties.

    Hope this helps!
     
    misohoni, Apr 18, 2006 IP
  4. NuPagady

    NuPagady Peon

    Messages:
    4
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    I didn't have a Chinese font, trying to find one now.

    Yes, I store data to mysql using utf8 charset, but I add letters to image before I put them to database, so that's not the case. However, I will try to change encoding for PHP files.


    Thanks for your help.
     
    NuPagady, Apr 18, 2006 IP
  5. digitalpoint

    digitalpoint Overlord of no one Staff

    Messages:
    38,334
    Likes Received:
    2,613
    Best Answers:
    462
    Trophy Points:
    710
    Digital Goods:
    29
    #5
    The best font for unicode stuff I've run across is Microsoft's unicode Arial font that comes with Microsoft Office. If you have Office installed, see if you have the arialuni.ttf file installed. If not, search Google for the file, you can probably find it somewhere:

    [search=google]arialuni.ttf[/search]
     
    digitalpoint, Apr 18, 2006 IP
  6. misohoni

    misohoni Notable Member

    Messages:
    1,717
    Likes Received:
    32
    Best Answers:
    0
    Trophy Points:
    200
    #6
    You may of already got the Chinese font installed...go to Firefox, within the view function select UTF8 and see if that makes a difference.
     
    misohoni, Apr 18, 2006 IP
  7. NuPagady

    NuPagady Peon

    Messages:
    4
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Yes, arialuni.ttf helped. Everything works fine now. Thank you very much!
     
    NuPagady, Apr 18, 2006 IP