| 1 |
lars |
1 |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
|
|
|
2 |
<HTML>
|
|
|
3 |
<HEAD>
|
|
|
4 |
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=iso-iso-8859-1">
|
|
|
5 |
<LINK REL="Start" HREF="index.html">
|
|
|
6 |
<LINK REL="Contents" HREF="toc.html">
|
|
|
7 |
<LINK REL="Prev" HREF="313PreparingTrueTypeFontFiles.html">
|
|
|
8 |
<LINK REL="Next" HREF="32Customizingtheinstallation.html">
|
|
|
9 |
<STYLE TYPE="text/css"><!--
|
|
|
10 |
BODY { font-family: serif }
|
|
|
11 |
H1 { font-family: sans-serif }
|
|
|
12 |
H2 { font-family: sans-serif }
|
|
|
13 |
H3 { font-family: sans-serif }
|
|
|
14 |
H4 { font-family: sans-serif }
|
|
|
15 |
H5 { font-family: sans-serif }
|
|
|
16 |
H6 { font-family: sans-serif }
|
|
|
17 |
SUB { font-size: smaller }
|
|
|
18 |
SUP { font-size: smaller }
|
|
|
19 |
PRE { font-family: monospace }
|
|
|
20 |
A { text-decoration: none }
|
|
|
21 |
--></STYLE>
|
|
|
22 |
</HEAD>
|
|
|
23 |
<BODY>
|
|
|
24 |
<A HREF="toc.html">Contents</A>
|
|
|
25 |
<A HREF="313PreparingTrueTypeFontFiles.html">Previous</A>
|
|
|
26 |
<A HREF="32Customizingtheinstallation.html">Next</A>
|
|
|
27 |
<HR NOSHADE>
|
|
|
28 |
<H3><A NAME="3_1_4">3.1.4 Using non-latin based fonts with JpGraph</A></H3>
|
|
|
29 |
<P> In addition to European font it is also possible to use non-latin
|
|
|
30 |
based fonts such as Cyrillic, Japanese and Chinese.</P>
|
|
|
31 |
<P> In all cases a suitable TTF font that supports the non-latin based
|
|
|
32 |
language must be available.</P>
|
|
|
33 |
<P> For Cyrillic support the define LANGUAGE_CYRILLIC in jpg-config.php
|
|
|
34 |
must be set to true. It is then possible to use a suitable Cyrillic
|
|
|
35 |
font as replacement for the ordinary fonts.</P>
|
|
|
36 |
<P> For Chinese character set JpGraph supports both BIG5 and GB2312
|
|
|
37 |
encoding. For BIG5 encoding the PHP installation must have support for
|
|
|
38 |
the "iconv()" function. Furthermore the define CHINESE_TTF_FONT must be
|
|
|
39 |
set to the name of the Chinese BIG5 font that is to be used. By default
|
|
|
40 |
this is set to "bkai00mp.ttf". To use the Chinese BIG5 font in the
|
|
|
41 |
scripts one must then specify the font family as FF_CHINESE.</P>
|
|
|
42 |
<P> To use the alternative font files "simsun.ttc" and "simhei.ttf"
|
|
|
43 |
(which uses the GB2312 encoding) the only step needed is to install
|
|
|
44 |
those fonts in the normal TTF font directory and then specify the font
|
|
|
45 |
family as FF_SIMSUN, the "simhei.ttf" is used when the font style is
|
|
|
46 |
specified as FS_BOLD.</P>
|
|
|
47 |
<H4>3.1.4.1 Japanese character support</H4>
|
|
|
48 |
Using Japanese fonts are supported by the pre-defined font families
|
|
|
49 |
<UL>
|
|
|
50 |
<LI>FF_MINCHO</LI>
|
|
|
51 |
<LI>FF_PMINCHO</LI>
|
|
|
52 |
<LI>FF_GOTHIC</LI>
|
|
|
53 |
<LI>FF_PGOTHIC</LI>
|
|
|
54 |
</UL>
|
|
|
55 |
Please note that the actual font files is not included in the library.
|
|
|
56 |
The exact name of the font files to use for these families are defined
|
|
|
57 |
in the the configuration file "jpg-config.inc.php.php".
|
|
|
58 |
<P> Some care must be taken due to the encoding that the library
|
|
|
59 |
expects. The library TTF handling expects the fonts to be encoded in
|
|
|
60 |
UTF8 encoding. Since the most commonly used Japanese encoding is EUC-JP
|
|
|
61 |
some conversion must be done. The best way to do this is by using the<I>
|
|
|
62 |
mbstring</I> extension to PHP to handle the encoding. By default this
|
|
|
63 |
module is not included and to compile PHP with support for mbstring the
|
|
|
64 |
option "--enable-mbstring" must be given when compiling PHP. Your
|
|
|
65 |
installation of PHP might also provide mbstring as a PHP module that is
|
|
|
66 |
loaded at runtime.</P>
|
|
|
67 |
<P> To convert from EUC-JP the function<I> mb_convert_encoding()</I> is
|
|
|
68 |
used as the following example shows.</P>
|
|
|
69 |
<PRE>
|
|
|
70 |
$utf8-encoded-text = mb_convert_encoding($eucjp-encoded-txt, 'UTF-8','EUC-JP');
|
|
|
71 |
</PRE>
|
|
|
72 |
By enabling the define "ASSUME_EUCJP_ENCODING" (in
|
|
|
73 |
jpg-config.inc.php.php) this encoding is done automatically in the
|
|
|
74 |
library when one of the Japanese fonts have been enabled. By default
|
|
|
75 |
this automatic conversion is disabled.
|
|
|
76 |
<P> If this define is false then it is up to the client to make sure
|
|
|
77 |
that the proper utf8 encoded text is passed on to all the methods that
|
|
|
78 |
are use to specify text in the library given that one of the Japanese
|
|
|
79 |
fonts have been selected.</P>
|
|
|
80 |
<P> A different method also exists when it comes to Japanese font
|
|
|
81 |
support. By compiling PHP with the option "--enable-gd-jis-conv" this
|
|
|
82 |
will automatically convert Japanese characters to UTF8 when using the
|
|
|
83 |
FreeType libraries. However the method with the mbstring module is
|
|
|
84 |
preferred since the automatic conversion might on occasion fail to
|
|
|
85 |
detect the proper encoding.</P>
|
|
|
86 |
<HR NOSHADE>
|
|
|
87 |
<A HREF="toc.html">Contents</A>
|
|
|
88 |
<A HREF="313PreparingTrueTypeFontFiles.html">Previous</A>
|
|
|
89 |
<A HREF="32Customizingtheinstallation.html">Next</A>
|
|
|
90 |
</BODY>
|
|
|
91 |
</HTML>
|