Subversion Repositories Applications.annuaire

Rev

Rev 66 | Details | Compare with Previous | Last modification | View Log | RSS feed

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