PHP jpgraph Chinese use manual jpgraph font installation and configuration method

Source: Internet
Author: User
Tags character set config constant manual italic font php web development requires

After the introduction of the PHP jpgraph installation tutorial, you can use the Jpgraph class library in the context of installing PHP. But in order to allow the Jpgraph class library to better support a variety of characters, such as Chinese characters, we need to understand the Jpgraph class Library font configuration principles and reasonable configuration, the following I jpgraph in the form of a Chinese manual to introduce how to jpgraph font configuration, I hope to help friends who have just started using the Jpgraph class library.

The Jpgraph class library supports two types of fonts: Bitmap and TTF fonts. The advantage of the bitmap font is that the Jpgraph class library itself is supported and does not need to be reconfigured. The TTF font needs some configuration or it may need to install some real TTF font files.

On the other hand, using bitmap fonts also has drawbacks, such as

Bitmap fonts do not support italic font types

Bitmap fonts support only 7-bit ASCII characters

Only 0-90-degree rotated fonts are supported

  Jpgraph Configure TTF Fonts

  Note : This is an optional part because jpgraph can work even without TTF font support, but it is strongly recommended that you support the configuration of TTF fonts.

Let's assume that the FreeType class library is enabled and validated. (mainly through the Phpinfo function and the GD library to verify the specific reference jpgraph installation Tutorial: Validation system support Jpgraph installation method)

Due to various legal issues TTF fonts are not included in the Jpgraph release because many of the commonly used TTF font files are protected by copyright. The status of the most commonly used web-fonts (Microsoft Core fonts) is ambiguous. For years, Microsoft has released these fonts for free but has not been able to download them from Microsoft's homepage. You can download these fonts from the http://corefonts.sourceforge.net/URL.

Because there are a lot of high-quality TTF fonts can be used for free. You need to configure for the Jpgraph font, and in order for the Jpgraph class library to find the TTF font file, the first step is to ensure that the font path is defined correctly in the Jpgraph class library profile jpg-config.inc.php as follows:

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

2, locate and find ttf_dir (this definition may need to update according to the different system). The default font path has several values, depending on whether the Jpgraph class library is installed under a Windows system or a UNIX system.

3, if it is on the Windows platform, the TTF font path in the Jpgraph class library requires the use of a standard Windows font directory (C:\windows\fonts\)

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

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 Dejavu TTF fonts from Http://sourceforge.net/projects/dejavu

Jpgraph uses standard naming conventions to be able to find the right specific TTF font files.

If the Jpgraph class library is installed on a computer running a Windows system, it is recommended that you use a font file that already exists on Windows (that is, the C:\WINDOWS\FONTS directory)

If the Jpgraph class library is installed on a UNIX version of the system, depending on the UNIX version and the branch. The common directory for UNIX-installed fonts is/usr/share/fonts/truetype/, which, if run on X11, is usually stored in the/usr/x11r6/lib/x11/fonts/truetype/directory for TrueType fonts.

Finally, we note that the Jpgraph class library can use the Setuserfont () method to install fonts that are not supported by themselves. (Theoretically, you can also modify the Jpgraph class library source file to support other font files, as this requires changes to the library code that we are not discussing here further.) )

Free TTF fonts can be found at the following URLs

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 Libraries use non-Latin fonts

In addition to European fonts, you can also use fonts such as Cyrillic, Japanese, Chinese, Hebrew, and Greek non-Latin. For TTF fonts in these languages, the Jpgraph class library must be supported.

For Cyrillic support, the language_cyrillic in the Jpgraph class library configuration file jpg-config.php must be defined to be true. You can then use the Cyrillic font instead of the normal font. This setting, combined with cyrillic_from_windows and language_charset, can be used to fine-tune the processing of Cyrillic input.

1. If Language_cyrillic is set to flase, it will not be processed for Cyrillic characters.

2. If Cyrillic_from_windows is set to true, it means that the character encoding entered is assumed to use WINDOWS-1251 by default. The conversion is done by calling the convert_cyr_string ($aTxt, ' w ', ' K ') functions. Where $atxt represents the input string that needs to be encoded.

3, if Cyrillic_from_windows is set to false, it means that the character encoding entered is used by default koi8-r. Transformations need to be done in the following order

1
2
3
4
<?php
$isostring = convert_cyr_string ($aTxt, "K", "I");
$unistring = Languageconv::iso2uni ($isostring);
?>

Thus obtaining the correct UTF8 internal code. (only UTF8 encoding is used internally in the Jpgraph class library )

4. When using the Cyrillic character, the Language_charset option can be used to dynamically transform the input character set. If language_cyrillic=true, this constant can automatically detect whether a Cyrillic conversion must be made. This constant can also be set to a mutable set containing the currently available input characters. A typical string is UTF-8 or utf-8 (case-insensitive), and no conversion is required if the character set is neither Koi8-r nor windows-1251 derivative.

For the Chinese character set, the Jpgraph class library supports BIG5 and GB2312 encodings. For BIG5 encoding, the PHP runtime environment must support the ICONV () function. In addition, the name of the BIG5 font that must be set to use when defining Chinese_ttf_font. The default setting is Bkai00mp.ttf. To BIG5 fonts in a script, these fonts must be Ff_chinese font families.

In order to use the SIMSUN.TTC and Simhei.ttf (GB2312 encoded) fonts, the only step is to install the fonts in the normal TTF font directory, and it must be a Ff_simsun font family, when the font type is Fs_ Use Simhei.ttf font when Blod.

At this point, the Jpgraph class library font configuration is finished.

  Note : PHP Web Development Tutorials-leapsoul.cn Copyright, reproduced in the form of links to indicate the original source and this statement, thank you.







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.