Blame | Letzte Änderung | Log anzeigen | RSS feed
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd"><HTML><HEAD><META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=iso-iso-8859-1"><LINK REL="Start" HREF="index.html"><LINK REL="Contents" HREF="toc.html"><LINK REL="Prev" HREF="313PreparingTrueTypeFontFiles.html"><LINK REL="Next" HREF="32Customizingtheinstallation.html"><STYLE TYPE="text/css"><!--BODY { font-family: serif }H1 { font-family: sans-serif }H2 { font-family: sans-serif }H3 { font-family: sans-serif }H4 { font-family: sans-serif }H5 { font-family: sans-serif }H6 { font-family: sans-serif }SUB { font-size: smaller }SUP { font-size: smaller }PRE { font-family: monospace }A { text-decoration: none }--></STYLE></HEAD><BODY><A HREF="toc.html">Contents</A><A HREF="313PreparingTrueTypeFontFiles.html">Previous</A><A HREF="32Customizingtheinstallation.html">Next</A><HR NOSHADE><H3><A NAME="3_1_4">3.1.4 Using non-latin based fonts with JpGraph</A></H3><P> In addition to European font it is also possible to use non-latinbased fonts such as Cyrillic, Japanese and Chinese.</P><P> In all cases a suitable TTF font that supports the non-latin basedlanguage must be available.</P><P> For Cyrillic support the define LANGUAGE_CYRILLIC in jpg-config.phpmust be set to true. It is then possible to use a suitable Cyrillicfont as replacement for the ordinary fonts.</P><P> For Chinese character set JpGraph supports both BIG5 and GB2312encoding. For BIG5 encoding the PHP installation must have support forthe "iconv()" function. Furthermore the define CHINESE_TTF_FONT must beset to the name of the Chinese BIG5 font that is to be used. By defaultthis is set to "bkai00mp.ttf". To use the Chinese BIG5 font in thescripts one must then specify the font family as FF_CHINESE.</P><P> To use the alternative font files "simsun.ttc" and "simhei.ttf"(which uses the GB2312 encoding) the only step needed is to installthose fonts in the normal TTF font directory and then specify the fontfamily as FF_SIMSUN, the "simhei.ttf" is used when the font style isspecified as FS_BOLD.</P><H4>3.1.4.1 Japanese character support</H4>Using Japanese fonts are supported by the pre-defined font families<UL><LI>FF_MINCHO</LI><LI>FF_PMINCHO</LI><LI>FF_GOTHIC</LI><LI>FF_PGOTHIC</LI></UL>Please note that the actual font files is not included in the library.The exact name of the font files to use for these families are definedin the the configuration file "jpg-config.inc.php.php".<P> Some care must be taken due to the encoding that the libraryexpects. The library TTF handling expects the fonts to be encoded inUTF8 encoding. Since the most commonly used Japanese encoding is EUC-JPsome conversion must be done. The best way to do this is by using the<I>mbstring</I> extension to PHP to handle the encoding. By default thismodule is not included and to compile PHP with support for mbstring theoption "--enable-mbstring" must be given when compiling PHP. Yourinstallation of PHP might also provide mbstring as a PHP module that isloaded at runtime.</P><P> To convert from EUC-JP the function<I> mb_convert_encoding()</I> isused as the following example shows.</P><PRE>$utf8-encoded-text = mb_convert_encoding($eucjp-encoded-txt, 'UTF-8','EUC-JP');</PRE>By enabling the define "ASSUME_EUCJP_ENCODING" (injpg-config.inc.php.php) this encoding is done automatically in thelibrary when one of the Japanese fonts have been enabled. By defaultthis automatic conversion is disabled.<P> If this define is false then it is up to the client to make surethat the proper utf8 encoded text is passed on to all the methods thatare use to specify text in the library given that one of the Japanesefonts have been selected.</P><P> A different method also exists when it comes to Japanese fontsupport. By compiling PHP with the option "--enable-gd-jis-conv" thiswill automatically convert Japanese characters to UTF8 when using theFreeType libraries. However the method with the mbstring module ispreferred since the automatic conversion might on occasion fail todetect the proper encoding.</P><HR NOSHADE><A HREF="toc.html">Contents</A><A HREF="313PreparingTrueTypeFontFiles.html">Previous</A><A HREF="32Customizingtheinstallation.html">Next</A></BODY></HTML>