How does ImageString output Chinese characters to an image?

Source: Internet
Author: User
I tried to use iconv to transcode and output Chinese characters, but I still searched the internet for a long time without finding a solution. How can this be solved? I tried to use iconv to transcode and output Chinese characters, but it is still garbled.

$ S = "If your output is sunny"; $ ss = iconv ("gb2312", "utf8", $ s); $ im = ImageCreate (400,400 ); $ black = ImageColorAllocate ($ im, 0x5,200,200 x); ImageString ($ im, $ ss, $ black); Header ('content-Type: image/png '); ImagePNG ($ im );

I searched the internet for a long time and did not find a solution. How can this be solved?

Reply content:

I tried to use iconv to transcode and output Chinese characters, but it is still garbled.

$ S = "If your output is sunny"; $ ss = iconv ("gb2312", "utf8", $ s); $ im = ImageCreate (400,400 ); $ black = ImageColorAllocate ($ im, 0x5,200,200 x); ImageString ($ im, $ ss, $ black); Header ('content-Type: image/png '); ImagePNG ($ im );

I searched the internet for a long time and did not find a solution. How can this be solved?

Imagestring uses a dot matrix font. If you really want to use it, you need to construct a Chinese dot matrix font and then use imageloadfont to load it.
We recommend that you use the imagettftext function.


  

It is best to output Chinese Charactersimagettftext()

imagestringBasically powerless

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.