About the Chinese display of jpgraph ....

Source: Internet
Author: User
Show | Chinese
The last two days saw here a post ... There is jpgraph this dongdong, think it is really very practical, really help us in the graphics statistics save a lot of Kung fu, so have been in trial, and then see:
Note:this information is only given this for very advanced users. No free support'll ge given in the case for your run into difficulties trying to add new fonts. At the moment adding new fonts require code modifications as outlined below.

Here, my enthusiasm lost half .... Is it just a rookie like me who can only use Simsun.ttf? Later I tried to change the name of many Chinese fonts to Simsun.ttf, and found that most of the Chinese can be displayed correctly ... (may be all Chinese), do not dare to enjoy, now the use of the method posted to share with you (I think maybe already a lot of experts know the method, then I will be here shortcoming. ).


When you use a class that has text display, you must use the SetFont method to set the font with three parameters: font name, typeface, size. Currently in Chinese, jpgraph only supports SimSun fonts, and if you want to use them, add them in the following ways:
First in the jpgraph.php: DEFINE ("Ttf_dir", "/usr/local/fonts/ttf/"); Define the path of the font (you can put the font here later)
And then find this line in jpgraph.php. Note "//Chinese font"
It is defined below with a method like this: define ("Ff_simfang", 9);(which in order to be easy to understand, its format is: "Ff_" with the font name, "9" for the value of the constant, as long as it is not the same as his original value, which number is not a problem, as long as not too large)

Now to insinuate:
Find this comment "//constructor" (here, smart you must know what's going on), add something similar in the array:
Ff_simfang=>array (fs_normal=> ' Simfang ',fs_bold=> ',fs_italic=> ' ',fs_bolditalic=> '), an array that has four items , the first is the standard font, the second is bold, the third is italic, and the fourth is bold italic. Each item corresponds to a font file, their value is to go to the extension of the font file name, there is no need to fill in, in addition to the standard.
Come here, the general English font added has been completed, but the Chinese is still limited, the key in the following places:
Find Languageconv class, find "class Languageconv"
In the function convert () "elseif ($aFF = = = Ff_simsun)" This place with or ("| |") Add the font name you defined previously, such as "$aFF ===ff_simfang"

OK, now you try, you're done!!




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.