Phpjpgraph Chinese user manual-jpgraph font installation and configuration method

Source: Internet
Author: User
After the phpjpgraph installation tutorial is complete, you can use the jpgraph class library in the environment where PHP is installed. However, to enable the jpgraph class library to better support various characters, such as Chinese characters, we need to understand the font configuration principles of the jpgraph class library and make reasonable configuration, the following describes how to use the jpgraph class library in the php jpgraph installation tutorial. However, to enable the jpgraph class library to better support various characters, such as Chinese characters, we need to understand the font configuration principles of the jpgraph class library and make reasonable configuration, next I will introduce how to configure the jpgraph font in the form of the jpgraph Chinese manual. I hope it will help my friends who are just getting started with the jpgraph class library.

The jpgraph class library supports two types of fonts: bitmap and TTF. The advantage of bitmap fonts is that the jpgraph class library itself does not need to be configured. The TTF font requires some configurations, and some real TTF font files may need to be installed.

On the other hand, bitmap fonts also have disadvantages, such

Bitmap fonts do not support italic fonts

Bitmap font only supports 7-bit ASCII characters

Only 0 to 90 degrees of rotation fonts are supported.

  Configure TTF font in jpgraph

  Note:: This is an optional part because jpgraph works even if it does not support TTF fonts. However, we strongly recommend that you configure TTF fonts.

Next we assume that the FreeType class library has been enabled and has passed the verification. (For details about how to verify the GD library through the phpinfo function, refer to the jpgraph installation tutorial: verify that the system supports jpgraph installation)

Due to various legal issues, TTF fonts are not included in the JpGraph release, because many commonly used TTF font files are copyrighted. The most common WEB-fonts (Microsoft core fonts) are unclear. Although Microsoft has released these fonts for free for many years, they cannot be downloaded from Microsoft's homepage. You can download these fonts from http://corefonts.sourceforge.net/net/net.

Because there are many high-quality TTF fonts available for free. You need to configure the jpgraph font, in order to make the jpgraph class library can find the TTF font file, the first step needs to ensure that the font path in the jpgraph class library configuration file jpg-config.inc.php is correctly defined, the method is as follows:

1. open the jpgraph class library configuration file jpg-config.inc.php

2. locate and find TTF_DIR (this definition may be updated according to different system requirements ). The default font path has several values, depending on whether the jpgraph class library is installed in Windows or Unix.

3. on Windows, the TTF font path in the jpgraph class library must use the standard Windows font directory (C: \ windows \ fonts \)

4. if it is on a Unix platform, there may not be any TTF font installation. you can download and install it from http://corefonts.sourceforge.net. Many Linux versions can also automatically install these fonts.

5. You can also choose to install the available Vera Bitstream TTF font from http://www.gnome.org/fonts/

6. you can also choose to install the DejaVu TTF font from http://sourceforge.net/projects/dejavu.

JpGraph uses standard naming conventions to locate the correct TTF font file.

If the jpgraph class library is installed on a computer running Windows, we recommend that you use an existing font file (under the C: \ Windows \ FONTS directory) in WINDOWS)

If the jpgraph class library is installed on a Unix system, it depends on the Unix version and the branch. The common installation fonts for Unix are/usr/share/fonts/truetype/. if the installation fonts run on X11, generally, TrueType fonts are stored in the/usr/X11R6/lib/X11/fonts/truetype/directory.

Finally, we noticed that the jpgraph class library can use the SetUserFont () method to install fonts that are not supported by jpgraph. (Theoretically, you can modify the source file of the jpgraph class library to support other font files. we will not discuss the modification of the library code here .)

The free TTF font can be found at the following URL:

Http://www.webfontlist.com

Http://www.webpagepublicity.com/free-fonts.html

Http://www.fontonic.com/fonts.asp? Width = do & offset = 120

Http://www.fontspace.com/category/famous

  Jpgraph class library uses non-Latin fonts

In addition to European fonts, you can also use fonts such as Spanish, Japanese, Chinese, Hebrew, and Greek non-Latin. The jpgraph class library must support TTF fonts in these languages.

For support for Spanish files, you must define the cmdage_cyrillic in the jpgraph class library profile jpg-config.php to True. Then, you can use the Cyrillic font to replace the regular font. This setting, combined with CYRILLIC_FROM_WINDOWS and LANGUAGE_CHARSET, can be used to fine-tune the input for processing Cyrillic.

1. if LANGUAGE_CYRILLIC is set to Flase, Cyrillic characters are not processed.

2. if CYRILLIC_FROM_WINDOWS is set to True, it means that the input character encoding is WINDOWS-1251 by default. The conversion is done by callingConvert_cyr_string ($ aTxt, 'W', 'k ')Function. $ ATxt indicates the input string to be encoded.

3. if CYRILLIC_FROM_WINDOWS is set to False, it means that the entered character encoding uses the KOI8-R by default. The conversion must be performed in the following order:

1
2
3
4
$ Isostring = convert_cyr_string ($ aTxt, "k", "I ");
$ Unistring = LanguageConv: iso2uni ($ isostring );
?>

To obtain the correct UTF8 internal encoding. (Only UTF8 encoding is used in the jpgraph class library.)

4. when Cyrillic is used, the LANGUAGE_CHARSET option can be used to dynamically convert the input character set. If cyclage_cyrillic = true, this constant can automatically detect whether Cyrillic conversion is required. This constant can also be set to a variable set that contains currently available input characters. A typical string is either a UTF-8 or UTF-8 (case-insensitive) and does not need to be converted if the character set is neither a KOI8-R nor a windows-1251 derivative.

For Chinese character sets, the jpgraph class library supports BIG5 and GB2312 encoding. For BIG5 encoding, the PHP runtime environment must support the iconv () function. In addition, the name of the BIG5 font must be set when the CHINESE_TTF_FONT is defined. The default value is bkai00mp. ttf. To use BIG5 fonts in scripts, these fonts must be FF_CHINESE fonts.

To use simsun. ttc and simhei. ttf (GB2312 encoding) font. the only step is to install these fonts in the normal TTF font directory, which must be the FF_SIMSUN font family. when the font type is FS_BLOD, simhei is used. ttf font.

Now, the font configuration of the jpgraph class library is complete.

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.