1<?php
2//=======================================================================
3// File:        jpgraph_ttf.inc.php
4// Description: Handling of TTF fonts
5// Created:     2006-11-19
6// Ver:         $Id: jpgraph_ttf.inc.php 1858 2009-09-28 14:39:51Z ljp $
7//
8// Copyright (c) Asial Corporation. All rights reserved.
9//========================================================================
10
11// TTF Font families
12define("FF_COURIER",10);
13define("FF_VERDANA",11);
14define("FF_TIMES",12);
15define("FF_COMIC",14);
16define("FF_ARIAL",15);
17define("FF_GEORGIA",16);
18define("FF_TREBUCHE",17);
19
20// Gnome Vera font
21// Available from http://www.gnome.org/fonts/
22define("FF_VERA",18);
23define("FF_VERAMONO",19);
24define("FF_VERASERIF",20);
25
26// Chinese font
27define("FF_SIMSUN",30);
28define("FF_CHINESE",31);
29define("FF_BIG5",32);
30
31// Japanese font
32define("FF_MINCHO",40);
33define("FF_PMINCHO",41);
34define("FF_GOTHIC",42);
35define("FF_PGOTHIC",43);
36
37// Hebrew fonts
38define("FF_DAVID",44);
39define("FF_MIRIAM",45);
40define("FF_AHRON",46);
41
42// Dejavu-fonts http://sourceforge.net/projects/dejavu
43define("FF_DV_SANSSERIF",47);
44define("FF_DV_SERIF",48);
45define("FF_DV_SANSSERIFMONO",49);
46define("FF_DV_SERIFCOND",50);
47define("FF_DV_SANSSERIFCOND",51);
48
49// Extra fonts
50// Download fonts from
51// http://www.webfontlist.com
52// http://www.webpagepublicity.com/free-fonts.html
53// http://www.fontonic.com/fonts.asp?width=d&offset=120
54// http://www.fontspace.com/category/famous
55
56// define("FF_SPEEDO",71);  // This font is also known as Bauer (Used for development gauge fascia)
57define("FF_DIGITAL",72); // Digital readout font
58define("FF_COMPUTER",73); // The classic computer font
59define("FF_CALCULATOR",74); // Triad font
60
61define("FF_USERFONT",90);
62define("FF_USERFONT1",90);
63define("FF_USERFONT2",91);
64define("FF_USERFONT3",92);
65
66// Limits for fonts
67define("_FIRST_FONT",10);
68define("_LAST_FONT",99);
69
70// TTF Font styles
71define("FS_NORMAL",9001);
72define("FS_BOLD",9002);
73define("FS_ITALIC",9003);
74define("FS_BOLDIT",9004);
75define("FS_BOLDITALIC",9004);
76
77//Definitions for internal font
78define("FF_FONT0",1);
79define("FF_FONT1",2);
80define("FF_FONT2",4);
81
82//------------------------------------------------------------------------
83// Defines for font setup
84//------------------------------------------------------------------------
85
86// Actual name of the TTF file used together with FF_CHINESE aka FF_BIG5
87// This is the TTF file being used when the font family is specified as
88// either FF_CHINESE or FF_BIG5
89define('CHINESE_TTF_FONT','bkai00mp.ttf');
90
91// Special unicode greek language support
92define("LANGUAGE_GREEK",false);
93
94// If you are setting this config to true the conversion of greek characters
95// will assume that the input text is windows 1251
96define("GREEK_FROM_WINDOWS",false);
97
98// Special unicode cyrillic language support
99define("LANGUAGE_CYRILLIC",false);
100
101// If you are setting this config to true the conversion
102// will assume that the input text is windows 1251, if
103// false it will assume koi8-r
104define("CYRILLIC_FROM_WINDOWS",false);
105
106// The following constant is used to auto-detect
107// whether cyrillic conversion is really necessary
108// if enabled. Just replace 'windows-1251' with a variable
109// containing the input character encoding string
110// of your application calling jpgraph.
111// A typical such string would be 'UTF-8' or 'utf-8'.
112// The comparison is case-insensitive.
113// If this charset is not a 'koi8-r' or 'windows-1251'
114// derivate then no conversion is done.
115//
116// This constant can be very important in multi-user
117// multi-language environments where a cyrillic conversion
118// could be needed for some cyrillic people
119// and resulting in just erraneous conversions
120// for not-cyrillic language based people.
121//
122// Example: In the free project management
123// software dotproject.net $locale_char_set is dynamically
124// set by the language environment the user has chosen.
125//
126// Usage: define('LANGUAGE_CHARSET', $locale_char_set);
127//
128// where $locale_char_set is a GLOBAL (string) variable
129// from the application including JpGraph.
130//
131define('LANGUAGE_CHARSET', null);
132
133// Japanese TrueType font used with FF_MINCHO, FF_PMINCHO, FF_GOTHIC, FF_PGOTHIC
134// Standard fonts from Infomation-technology Promotion Agency (IPA)
135// See http://mix-mplus-ipa.sourceforge.jp/
136define('MINCHO_TTF_FONT','ipam.ttf');
137define('PMINCHO_TTF_FONT','ipamp.ttf');
138define('GOTHIC_TTF_FONT','ipag.ttf');
139define('PGOTHIC_TTF_FONT','ipagp.ttf');
140
141// Assume that Japanese text have been entered in EUC-JP encoding.
142// If this define is true then conversion from EUC-JP to UTF8 is done
143// automatically in the library using the mbstring module in PHP.
144define('ASSUME_EUCJP_ENCODING',false);
145
146
147// Default font family
148define('FF_DEFAULT', FF_DV_SANSSERIF);
149
150
151
152//=================================================================
153// CLASS LanguageConv
154// Description:
155// Converts various character encoding into proper
156// UTF-8 depending on how the library have been configured and
157// what font family is being used
158//=================================================================
159class LanguageConv {
160    private $g2312 = null ;
161
162    function Convert($aTxt,$aFF) {
163        if( LANGUAGE_GREEK ) {
164            if( GREEK_FROM_WINDOWS ) {
165                $unistring = LanguageConv::gr_win2uni($aTxt);
166            } else  {
167                $unistring = LanguageConv::gr_iso2uni($aTxt);
168            }
169            return $unistring;
170        } elseif( LANGUAGE_CYRILLIC ) {
171            if( CYRILLIC_FROM_WINDOWS && (!defined('LANGUAGE_CHARSET') || stristr(LANGUAGE_CHARSET, 'windows-1251')) ) {
172                $aTxt = convert_cyr_string($aTxt, "w", "k");
173            }
174            if( !defined('LANGUAGE_CHARSET') || stristr(LANGUAGE_CHARSET, 'koi8-r') || stristr(LANGUAGE_CHARSET, 'windows-1251')) {
175                $isostring = convert_cyr_string($aTxt, "k", "i");
176                $unistring = LanguageConv::iso2uni($isostring);
177            }
178            else {
179                $unistring = $aTxt;
180            }
181            return $unistring;
182        }
183        elseif( $aFF === FF_SIMSUN ) {
184            // Do Chinese conversion
185            if( $this->g2312 == null ) {
186                include_once 'jpgraph_gb2312.php' ;
187                $this->g2312 = new GB2312toUTF8();
188            }
189            return $this->g2312->gb2utf8($aTxt);
190        }
191        elseif( $aFF === FF_BIG5 ) {
192            if( !function_exists('iconv') ) {
193                JpGraphError::RaiseL(25006);
194                //('Usage of FF_CHINESE (FF_BIG5) font family requires that your PHP setup has the iconv() function. By default this is not compiled into PHP (needs the "--width-iconv" when configured).');
195            }
196            return iconv('BIG5','UTF-8',$aTxt);
197        }
198        elseif( ASSUME_EUCJP_ENCODING &&
199        ($aFF == FF_MINCHO || $aFF == FF_GOTHIC || $aFF == FF_PMINCHO || $aFF == FF_PGOTHIC) ) {
200            if( !function_exists('mb_convert_encoding') ) {
201                JpGraphError::RaiseL(25127);
202            }
203            return mb_convert_encoding($aTxt, 'UTF-8','EUC-JP');
204        }
205        elseif( $aFF == FF_DAVID || $aFF == FF_MIRIAM || $aFF == FF_AHRON ) {
206            return LanguageConv::heb_iso2uni($aTxt);
207        }
208        else
209        return $aTxt;
210    }
211
212    // Translate iso encoding to unicode
213    public static function iso2uni ($isoline){
214        $uniline='';
215        for ($i=0; $i < strlen($isoline); $i++){
216            $thischar=substr($isoline,$i,1);
217            $charcode=ord($thischar);
218            $uniline.=($charcode>175) ? "&#" . (1040+($charcode-176)). ";" : $thischar;
219        }
220        return $uniline;
221    }
222
223    // Translate greek iso encoding to unicode
224    public static function gr_iso2uni ($isoline) {
225        $uniline='';
226        for ($i=0; $i < strlen($isoline); $i++) {
227            $thischar=substr($isoline,$i,1);
228            $charcode=ord($thischar);
229            $uniline.=($charcode>179 && $charcode!=183 && $charcode!=187 && $charcode!=189) ? "&#" . (900+($charcode-180)). ";" : $thischar;
230        }
231        return $uniline;
232    }
233
234    // Translate greek win encoding to unicode
235    public static function gr_win2uni ($winline) {
236        $uniline='';
237        for ($i=0; $i < strlen($winline); $i++) {
238            $thischar=substr($winline,$i,1);
239            $charcode=ord($thischar);
240            if ($charcode==161 || $charcode==162) {
241                $uniline.="&#" . (740+$charcode). ";";
242            }
243            else {
244                $uniline.=(($charcode>183 && $charcode!=187 && $charcode!=189) || $charcode==180) ? "&#" . (900+($charcode-180)). ";" : $thischar;
245            }
246        }
247        return $uniline;
248    }
249
250    public static function heb_iso2uni($isoline) {
251        $isoline = hebrev($isoline);
252        $o = '';
253
254        $n = strlen($isoline);
255        for($i=0; $i < $n; $i++) {
256            $c=ord( substr($isoline,$i,1) );
257            $o .= ($c > 223) && ($c < 251) ? '&#'.(1264+$c).';' : chr($c);
258        }
259        return utf8_encode($o);
260    }
261}
262
263//=============================================================
264// CLASS TTF
265// Description: Handle TTF font names and mapping and loading of
266//              font files
267//=============================================================
268class TTF {
269    private $font_files,$style_names;
270
271    function __construct() {
272
273	        // String names for font styles to be used in error messages
274	    $this->style_names=array(
275	    	FS_NORMAL =>'normal',
276	    	FS_BOLD =>'bold',
277	    	FS_ITALIC =>'italic',
278	    	FS_BOLDITALIC =>'bolditalic');
279
280	    // File names for available fonts
281	    $this->font_files=array(
282	    FF_COURIER => array(FS_NORMAL =>'cour.ttf',
283	    	FS_BOLD  =>'courbd.ttf',
284	    	FS_ITALIC =>'couri.ttf',
285	    	FS_BOLDITALIC =>'courbi.ttf' ),
286	    FF_GEORGIA => array(FS_NORMAL =>'georgia.ttf',
287	    	FS_BOLD  =>'georgiab.ttf',
288	    	FS_ITALIC =>'georgiai.ttf',
289	    	FS_BOLDITALIC =>'' ),
290	    FF_TREBUCHE =>array(FS_NORMAL =>'trebuc.ttf',
291	    	FS_BOLD  =>'trebucbd.ttf',
292	    	FS_ITALIC =>'trebucit.ttf',
293	    	FS_BOLDITALIC =>'trebucbi.ttf' ),
294	    FF_VERDANA  => array(FS_NORMAL =>'verdana.ttf',
295	    	FS_BOLD  =>'verdanab.ttf',
296	    	FS_ITALIC =>'verdanai.ttf',
297	    	FS_BOLDITALIC =>'' ),
298	    FF_TIMES =>   array(FS_NORMAL =>'times.ttf',
299	    	FS_BOLD  =>'timesbd.ttf',
300	    	FS_ITALIC =>'timesi.ttf',
301	    	FS_BOLDITALIC =>'timesbi.ttf' ),
302	    FF_COMIC =>   array(FS_NORMAL =>'comic.ttf',
303	    	FS_BOLD  =>'comicbd.ttf',
304	    	FS_ITALIC =>'',
305	    	FS_BOLDITALIC =>'' ),
306	    FF_ARIAL =>   array(FS_NORMAL =>'arial.ttf',
307	    	FS_BOLD  =>'arialbd.ttf',
308	    	FS_ITALIC =>'ariali.ttf',
309	    	FS_BOLDITALIC =>'arialbi.ttf' ) ,
310	    FF_VERA =>    array(FS_NORMAL =>'Vera.ttf',
311	    	FS_BOLD  =>'VeraBd.ttf',
312	    	FS_ITALIC =>'VeraIt.ttf',
313	    	FS_BOLDITALIC =>'VeraBI.ttf' ),
314	    FF_VERAMONO => array(FS_NORMAL =>'VeraMono.ttf',
315	    	FS_BOLD =>'VeraMoBd.ttf',
316	    	FS_ITALIC =>'VeraMoIt.ttf',
317	    	FS_BOLDITALIC =>'VeraMoBI.ttf' ),
318	    FF_VERASERIF=> array(FS_NORMAL =>'VeraSe.ttf',
319	    	FS_BOLD =>'VeraSeBd.ttf',
320	    	FS_ITALIC =>'',
321	    	FS_BOLDITALIC =>'' ) ,
322
323	    /* Chinese fonts */
324	    FF_SIMSUN  =>  array(
325	    	FS_NORMAL =>'simsun.ttc',
326	    	FS_BOLD =>'simhei.ttf',
327	    	FS_ITALIC =>'',
328	    	FS_BOLDITALIC =>'' ),
329	    FF_CHINESE  =>   array(
330	    	FS_NORMAL =>CHINESE_TTF_FONT,
331	    	FS_BOLD =>'',
332	    	FS_ITALIC =>'',
333	    	FS_BOLDITALIC =>'' ),
334	    FF_BIG5  =>   array(
335	    	FS_NORMAL =>CHINESE_TTF_FONT,
336	    	FS_BOLD =>'',
337	    	FS_ITALIC =>'',
338	    	FS_BOLDITALIC =>'' ),
339
340	    /* Japanese fonts */
341	    FF_MINCHO  =>  array(
342	    	FS_NORMAL =>MINCHO_TTF_FONT,
343	    	FS_BOLD =>'',
344	    	FS_ITALIC =>'',
345	    	FS_BOLDITALIC =>'' ),
346
347	    FF_PMINCHO  =>  array(
348	    	FS_NORMAL =>PMINCHO_TTF_FONT,
349	    	FS_BOLD =>'',
350	    	FS_ITALIC =>'',
351	    	FS_BOLDITALIC =>'' ),
352
353	    FF_GOTHIC   =>  array(
354	    	FS_NORMAL =>GOTHIC_TTF_FONT,
355	    	FS_BOLD =>'',
356	    	FS_ITALIC =>'',
357	    	FS_BOLDITALIC =>'' ),
358
359	    FF_PGOTHIC  =>  array(
360	    	FS_NORMAL =>PGOTHIC_TTF_FONT,
361	    	FS_BOLD =>'',
362	    	FS_ITALIC =>'',
363	    	FS_BOLDITALIC =>'' ),
364
365	    /* Hebrew fonts */
366	    FF_DAVID  =>  array(
367	    	FS_NORMAL =>'DAVIDNEW.TTF',
368	    	FS_BOLD =>'',
369	    	FS_ITALIC =>'',
370	    	FS_BOLDITALIC =>'' ),
371
372	    FF_MIRIAM  =>  array(
373	    	FS_NORMAL =>'MRIAMY.TTF',
374	    	FS_BOLD =>'',
375	    	FS_ITALIC =>'',
376	    	FS_BOLDITALIC =>'' ),
377
378	    FF_AHRON  =>  array(
379	    	FS_NORMAL =>'ahronbd.ttf',
380	    	FS_BOLD =>'',
381	    	FS_ITALIC =>'',
382	    	FS_BOLDITALIC =>'' ),
383
384	    /* Misc fonts */
385	    FF_DIGITAL =>   array(
386	    	FS_NORMAL =>'DIGIRU__.TTF',
387	    	FS_BOLD =>'Digirtu_.ttf',
388	    	FS_ITALIC =>'Digir___.ttf',
389	    	FS_BOLDITALIC =>'DIGIRT__.TTF' ),
390
391	    /* This is an experimental font for the speedometer development
392	    FF_SPEEDO =>    array(
393	    FS_NORMAL =>'Speedo.ttf',
394	    FS_BOLD =>'',
395	    FS_ITALIC =>'',
396	    FS_BOLDITALIC =>'' ),
397	    */
398
399	    FF_COMPUTER  =>  array(
400	    	FS_NORMAL =>'COMPUTER.TTF',
401	    	FS_BOLD =>'',
402	    	FS_ITALIC =>'',
403	    	FS_BOLDITALIC =>'' ),
404
405	    FF_CALCULATOR => array(
406	    	FS_NORMAL =>'Triad_xs.ttf',
407	    	FS_BOLD =>'',
408	    	FS_ITALIC =>'',
409	    	FS_BOLDITALIC =>'' ),
410
411	    /* Dejavu fonts */
412	    FF_DV_SANSSERIF => array(
413	    	FS_NORMAL =>array('DejaVuSans.ttf'),
414	    	FS_BOLD =>array('DejaVuSans-Bold.ttf','DejaVuSansBold.ttf'),
415	    	FS_ITALIC =>array('DejaVuSans-Oblique.ttf','DejaVuSansOblique.ttf'),
416	    	FS_BOLDITALIC =>array('DejaVuSans-BoldOblique.ttf','DejaVuSansBoldOblique.ttf') ),
417
418	    FF_DV_SANSSERIFMONO => array(
419	    	FS_NORMAL =>array('DejaVuSansMono.ttf','DejaVuMonoSans.ttf'),
420	    	FS_BOLD =>array('DejaVuSansMono-Bold.ttf','DejaVuMonoSansBold.ttf'),
421	    	FS_ITALIC =>array('DejaVuSansMono-Oblique.ttf','DejaVuMonoSansOblique.ttf'),
422	    	FS_BOLDITALIC =>array('DejaVuSansMono-BoldOblique.ttf','DejaVuMonoSansBoldOblique.ttf') ),
423
424	    FF_DV_SANSSERIFCOND => array(
425	    	FS_NORMAL =>array('DejaVuSansCondensed.ttf','DejaVuCondensedSans.ttf'),
426	    	FS_BOLD =>array('DejaVuSansCondensed-Bold.ttf','DejaVuCondensedSansBold.ttf'),
427	    	FS_ITALIC =>array('DejaVuSansCondensed-Oblique.ttf','DejaVuCondensedSansOblique.ttf'),
428	    	FS_BOLDITALIC =>array('DejaVuSansCondensed-BoldOblique.ttf','DejaVuCondensedSansBoldOblique.ttf') ),
429
430	    FF_DV_SERIF => array(
431	    	FS_NORMAL =>array('DejaVuSerif.ttf'),
432	    	FS_BOLD =>array('DejaVuSerif-Bold.ttf','DejaVuSerifBold.ttf'),
433	    	FS_ITALIC =>array('DejaVuSerif-Italic.ttf','DejaVuSerifItalic.ttf'),
434	    	FS_BOLDITALIC =>array('DejaVuSerif-BoldItalic.ttf','DejaVuSerifBoldItalic.ttf') ),
435
436	    FF_DV_SERIFCOND => array(
437	    	FS_NORMAL =>array('DejaVuSerifCondensed.ttf','DejaVuCondensedSerif.ttf'),
438	    	FS_BOLD =>array('DejaVuSerifCondensed-Bold.ttf','DejaVuCondensedSerifBold.ttf'),
439	    	FS_ITALIC =>array('DejaVuSerifCondensed-Italic.ttf','DejaVuCondensedSerifItalic.ttf'),
440	    	FS_BOLDITALIC =>array('DejaVuSerifCondensed-BoldItalic.ttf','DejaVuCondensedSerifBoldItalic.ttf') ),
441
442
443	    /* Placeholders for defined fonts */
444	    FF_USERFONT1 => array(
445	    	FS_NORMAL =>'',
446	    	FS_BOLD =>'',
447	    	FS_ITALIC =>'',
448	    	FS_BOLDITALIC =>'' ),
449
450	    FF_USERFONT2 => array(
451	    	FS_NORMAL =>'',
452	    	FS_BOLD =>'',
453	    	FS_ITALIC =>'',
454	    	FS_BOLDITALIC =>'' ),
455
456	    FF_USERFONT3 => array(
457	    	FS_NORMAL =>'',
458	    	FS_BOLD =>'',
459	    	FS_ITALIC =>'',
460	    	FS_BOLDITALIC =>'' ),
461
462	    );
463    }
464
465    //---------------
466    // PUBLIC METHODS
467    // Create the TTF file from the font specification
468    function File($family,$style=FS_NORMAL) {
469        $fam = @$this->font_files[$family];
470        if( !$fam ) {
471            JpGraphError::RaiseL(25046,$family);//("Specified TTF font family (id=$family) is unknown or does not exist. Please note that TTF fonts are not distributed with JpGraph for copyright reasons. You can find the MS TTF WEB-fonts (arial, courier etc) for download at http://corefonts.sourceforge.net/");
472        }
473        $ff = @$fam[$style];
474
475        // There are several optional file names. They are tried in order
476        // and the first one found is used
477        if( !is_array($ff) ) {
478            $ff = array($ff);
479        }
480
481        $jpgraph_font_dir = dirname(__FILE__).'/fonts/';
482
483        foreach ($ff as $font_file) {
484            // All font families are guaranteed to have the normal style
485
486            if( $font_file==='' )
487                    JpGraphError::RaiseL(25047,$this->style_names[$style],$this->font_files[$family][FS_NORMAL]);//('Style "'.$this->style_names[$style].'" is not available for font family '.$this->font_files[$family][FS_NORMAL].'.');
488            if( !$font_file ) {
489                JpGraphError::RaiseL(25048,$fam);//("Unknown font style specification [$fam].");
490            }
491
492            // check jpgraph/src/fonts dir
493            $jpgraph_font_file = $jpgraph_font_dir . $font_file;
494            if (file_exists($jpgraph_font_file) === true && is_readable($jpgraph_font_file) === true) {
495                $font_file = $jpgraph_font_file;
496                break;
497            }
498
499            // check OS font dir
500            if ($family >= FF_MINCHO && $family <= FF_PGOTHIC) {
501                $font_file = MBTTF_DIR.$font_file;
502            } else {
503                $font_file = TTF_DIR.$font_file;
504            }
505            if (file_exists($font_file) === true && is_readable($font_file) === true) {
506                break;
507            }
508        }
509
510        if( !file_exists($font_file) ) {
511        	JpGraphError::RaiseL(25049,$font_file);//("Font file \"$font_file\" is not readable or does not exist.");
512        }
513
514        return $font_file;
515    }
516
517    function SetUserFont($aNormal,$aBold='',$aItalic='',$aBoldIt='') {
518        $this->font_files[FF_USERFONT] =
519        	array(FS_NORMAL     => $aNormal,
520        		  FS_BOLD => $aBold,
521        		  FS_ITALIC => $aItalic,
522        		  FS_BOLDITALIC => $aBoldIt ) ;
523    }
524
525    function SetUserFont1($aNormal,$aBold='',$aItalic='',$aBoldIt='') {
526        $this->font_files[FF_USERFONT1] =
527        	array(FS_NORMAL     => $aNormal,
528        		  FS_BOLD => $aBold,
529        		  FS_ITALIC => $aItalic,
530        		  FS_BOLDITALIC => $aBoldIt ) ;
531    }
532
533    function SetUserFont2($aNormal,$aBold='',$aItalic='',$aBoldIt='') {
534        $this->font_files[FF_USERFONT2] =
535        	array(FS_NORMAL     => $aNormal,
536        		  FS_BOLD => $aBold,
537        		  FS_ITALIC => $aItalic,
538        		  FS_BOLDITALIC => $aBoldIt ) ;
539    }
540
541    function SetUserFont3($aNormal,$aBold='',$aItalic='',$aBoldIt='') {
542        $this->font_files[FF_USERFONT3] =
543        	array(FS_NORMAL     => $aNormal,
544        		  FS_BOLD => $aBold,
545        		  FS_ITALIC => $aItalic,
546        		  FS_BOLDITALIC => $aBoldIt ) ;
547    }
548
549} // Class
550
551
552//=============================================================================
553// CLASS SymChar
554// Description: Code values for some commonly used characters that
555//              normally isn't available directly on the keyboard, for example
556//              mathematical and greek symbols.
557//=============================================================================
558class  SymChar {
559    static function Get($aSymb,$aCapital=FALSE) {
560        $iSymbols = array(
561        /* Greek */
562        array('alpha','03B1','0391'),
563        array('beta','03B2','0392'),
564        array('gamma','03B3','0393'),
565        array('delta','03B4','0394'),
566        array('epsilon','03B5','0395'),
567        array('zeta','03B6','0396'),
568        array('ny','03B7','0397'),
569        array('eta','03B8','0398'),
570        array('theta','03B8','0398'),
571        array('iota','03B9','0399'),
572        array('kappa','03BA','039A'),
573        array('lambda','03BB','039B'),
574        array('mu','03BC','039C'),
575        array('nu','03BD','039D'),
576        array('xi','03BE','039E'),
577        array('omicron','03BF','039F'),
578        array('pi','03C0','03A0'),
579        array('rho','03C1','03A1'),
580        array('sigma','03C3','03A3'),
581        array('tau','03C4','03A4'),
582        array('upsilon','03C5','03A5'),
583        array('phi','03C6','03A6'),
584        array('chi','03C7','03A7'),
585        array('psi','03C8','03A8'),
586        array('omega','03C9','03A9'),
587        /* Money */
588        array('euro','20AC'),
589        array('yen','00A5'),
590        array('pound','20A4'),
591        /* Math */
592        array('approx','2248'),
593        array('neq','2260'),
594        array('not','2310'),
595        array('def','2261'),
596        array('inf','221E'),
597        array('sqrt','221A'),
598        array('int','222B'),
599        /* Misc */
600        array('copy','00A9'),
601        array('para','00A7'),
602        array('tm','2122'),   /* Trademark symbol */
603        array('rtm','00AE'),   /* Registered trademark */
604        array('degree','00b0'),
605        array('lte','2264'), /* Less than or equal */
606        array('gte','2265'), /* Greater than or equal */
607
608        );
609
610        $n = count($iSymbols);
611        $i=0;
612        $found = false;
613        $aSymb = strtolower($aSymb);
614        while( $i < $n && !$found ) {
615            $found = $aSymb === $iSymbols[$i++][0];
616        }
617        if( $found ) {
618            $ca = $iSymbols[--$i];
619            if( $aCapital && count($ca)==3 )
620                $s = $ca[2];
621            else
622                $s = $ca[1];
623            return sprintf('&#%04d;',hexdec($s));
624        }
625        else
626            return '';
627    }
628}
629
630
631?>
632