Changeset 265 for trunk/client/modules/Elezioni/grafici/jpgraph_ttf.inc.php
- Timestamp:
- Apr 13, 2019, 8:05:15 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/client/modules/Elezioni/grafici/jpgraph_ttf.inc.php
r2 r265 1 1 <?php 2 2 //======================================================================= 3 // File: 4 // Description: 5 // Created: 6 // Ver: $Id: jpgraph_ttf.inc.php 1091 2009-01-18 22:57:40Z ljp $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 7 // 8 // Copyright (c) A ditus Consulting. All rights reserved.8 // Copyright (c) Asial Corporation. All rights reserved. 9 9 //======================================================================== 10 10 … … 27 27 define("FF_SIMSUN",30); 28 28 define("FF_CHINESE",31); 29 define("FF_BIG5",3 1);29 define("FF_BIG5",32); 30 30 31 31 // Japanese font … … 48 48 49 49 // Extra fonts 50 // Download fonts from 50 // Download fonts from 51 51 // http://www.webfontlist.com 52 52 // http://www.webpagepublicity.com/free-fonts.html 53 54 define("FF_SPEEDO",71); // This font is also known as Bauer (Used for gauge fascia) 55 define("FF_DIGITAL",72); // Digital readout font 56 define("FF_COMPUTER",73); // The classic computer font 57 define("FF_CALCULATOR",74); // Triad font 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 58 60 59 61 define("FF_USERFONT",90); … … 78 80 define("FF_FONT2",4); 79 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 // Default font family 148 define('FF_DEFAULT', FF_DV_SANSSERIF); 149 150 151 80 152 //================================================================= 81 153 // CLASS LanguageConv 82 // Description: 154 // Description: 83 155 // Converts various character encoding into proper 84 156 // UTF-8 depending on how the library have been configured and … … 89 161 90 162 function Convert($aTxt,$aFF) { 91 92 93 $unistring = LanguageConv::gr_win2uni($aTxt); 94 95 96 97 98 99 100 $aTxt = convert_cyr_string($aTxt, "w", "k"); 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 elseif( $aFF === FF_CHINESE) {120 121 122 //('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).');123 124 125 126 127 128 129 130 131 132 133 134 135 136 else 137 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; 138 210 } 139 211 140 212 // Translate iso encoding to unicode 141 213 public static function iso2uni ($isoline){ 142 143 144 145 146 147 148 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; 149 221 } 150 222 151 223 // Translate greek iso encoding to unicode 152 224 public static function gr_iso2uni ($isoline) { 153 154 for ($i=0; $i < strlen($isoline); $i++){155 156 157 158 159 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; 160 232 } 161 233 162 234 // Translate greek win encoding to unicode 163 235 public static function gr_win2uni ($winline) { 164 165 166 167 168 169 170 171 172 173 174 175 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; 176 248 } 177 249 178 250 public static function heb_iso2uni($isoline) { 179 180 181 182 183 184 185 186 187 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); 188 260 } 189 261 } … … 191 263 //============================================================= 192 264 // CLASS TTF 193 // Description: Handle TTF font names and mapping and loading of 265 // Description: Handle TTF font names and mapping and loading of 194 266 // font files 195 267 //============================================================= … … 197 269 private $font_files,$style_names; 198 270 199 //--------------- 200 // CONSTRUCTOR 201 function TTF() { 202 203 // String names for font styles to be used in error messages 204 $this->style_names=array(FS_NORMAL =>'normal', 205 FS_BOLD =>'bold', 206 FS_ITALIC =>'italic', 207 FS_BOLDITALIC =>'bolditalic'); 208 209 // File names for available fonts 210 $this->font_files=array( 211 FF_COURIER => array(FS_NORMAL =>'cour.ttf', 212 FS_BOLD =>'courbd.ttf', 213 FS_ITALIC =>'couri.ttf', 214 FS_BOLDITALIC =>'courbi.ttf' ), 215 FF_GEORGIA => array(FS_NORMAL =>'georgia.ttf', 216 FS_BOLD =>'georgiab.ttf', 217 FS_ITALIC =>'georgiai.ttf', 218 FS_BOLDITALIC =>'' ), 219 FF_TREBUCHE =>array(FS_NORMAL =>'trebuc.ttf', 220 FS_BOLD =>'trebucbd.ttf', 221 FS_ITALIC =>'trebucit.ttf', 222 FS_BOLDITALIC =>'trebucbi.ttf' ), 223 FF_VERDANA => array(FS_NORMAL =>'verdana.ttf', 224 FS_BOLD =>'verdanab.ttf', 225 FS_ITALIC =>'verdanai.ttf', 226 FS_BOLDITALIC =>'' ), 227 FF_TIMES => array(FS_NORMAL =>'times.ttf', 228 FS_BOLD =>'timesbd.ttf', 229 FS_ITALIC =>'timesi.ttf', 230 FS_BOLDITALIC =>'timesbi.ttf' ), 231 FF_COMIC => array(FS_NORMAL =>'comic.ttf', 232 FS_BOLD =>'comicbd.ttf', 233 FS_ITALIC =>'', 234 FS_BOLDITALIC =>'' ), 235 FF_ARIAL => array(FS_NORMAL =>'arial.ttf', 236 FS_BOLD =>'arialbd.ttf', 237 FS_ITALIC =>'ariali.ttf', 238 FS_BOLDITALIC =>'arialbi.ttf' ) , 239 FF_VERA => array(FS_NORMAL =>'Vera.ttf', 240 FS_BOLD =>'VeraBd.ttf', 241 FS_ITALIC =>'VeraIt.ttf', 242 FS_BOLDITALIC =>'VeraBI.ttf' ), 243 FF_VERAMONO => array(FS_NORMAL =>'VeraMono.ttf', 244 FS_BOLD =>'VeraMoBd.ttf', 245 FS_ITALIC =>'VeraMoIt.ttf', 246 FS_BOLDITALIC =>'VeraMoBI.ttf' ), 247 FF_VERASERIF=> array(FS_NORMAL =>'VeraSe.ttf', 248 FS_BOLD =>'VeraSeBd.ttf', 249 FS_ITALIC =>'', 250 FS_BOLDITALIC =>'' ) , 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 =>'' ) , 251 322 252 323 /* Chinese fonts */ 253 FF_SIMSUN => array(FS_NORMAL =>'simsun.ttc', 254 FS_BOLD =>'simhei.ttf', 255 FS_ITALIC =>'', 256 FS_BOLDITALIC =>'' ), 257 FF_CHINESE => array(FS_NORMAL =>CHINESE_TTF_FONT, 258 FS_BOLD =>'', 259 FS_ITALIC =>'', 260 FS_BOLDITALIC =>'' ), 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 =>'' ), 261 339 262 340 /* Japanese fonts */ 263 FF_MINCHO => array(FS_NORMAL =>MINCHO_TTF_FONT, 264 FS_BOLD =>'', 265 FS_ITALIC =>'', 266 FS_BOLDITALIC =>'' ), 267 FF_PMINCHO => array(FS_NORMAL =>PMINCHO_TTF_FONT, 268 FS_BOLD =>'', 269 FS_ITALIC =>'', 270 FS_BOLDITALIC =>'' ), 271 FF_GOTHIC => array(FS_NORMAL =>GOTHIC_TTF_FONT, 272 FS_BOLD =>'', 273 FS_ITALIC =>'', 274 FS_BOLDITALIC =>'' ), 275 FF_PGOTHIC => array(FS_NORMAL =>PGOTHIC_TTF_FONT, 276 FS_BOLD =>'', 277 FS_ITALIC =>'', 278 FS_BOLDITALIC =>'' ), 279 FF_MINCHO => array(FS_NORMAL =>PMINCHO_TTF_FONT, 280 FS_BOLD =>'', 281 FS_ITALIC =>'', 282 FS_BOLDITALIC =>'' ), 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 =>'' ), 283 364 284 365 /* Hebrew fonts */ 285 FF_DAVID => array(FS_NORMAL =>'DAVIDNEW.TTF', 286 FS_BOLD =>'', 287 FS_ITALIC =>'', 288 FS_BOLDITALIC =>'' ), 289 290 FF_MIRIAM => array(FS_NORMAL =>'MRIAMY.TTF', 291 FS_BOLD =>'', 292 FS_ITALIC =>'', 293 FS_BOLDITALIC =>'' ), 294 295 FF_AHRON => array(FS_NORMAL =>'ahronbd.ttf', 296 FS_BOLD =>'', 297 FS_ITALIC =>'', 298 FS_BOLDITALIC =>'' ), 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 =>'' ), 299 383 300 384 /* Misc fonts */ 301 FF_DIGITAL => array(FS_NORMAL =>'DIGIRU__.TTF', 302 FS_BOLD =>'Digirtu_.ttf', 303 FS_ITALIC =>'Digir___.ttf', 304 FS_BOLDITALIC =>'DIGIRT__.TTF' ), 305 FF_SPEEDO => array(FS_NORMAL =>'Speedo.ttf', 306 FS_BOLD =>'', 307 FS_ITALIC =>'', 308 FS_BOLDITALIC =>'' ), 309 FF_COMPUTER => array(FS_NORMAL =>'COMPUTER.TTF', 310 FS_BOLD =>'', 311 FS_ITALIC =>'', 312 FS_BOLDITALIC =>'' ), 313 FF_CALCULATOR => array(FS_NORMAL =>'Triad_xs.ttf', 314 FS_BOLD =>'', 315 FS_ITALIC =>'', 316 FS_BOLDITALIC =>'' ), 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 =>'' ), 317 410 318 411 /* Dejavu fonts */ 319 FF_DV_SANSSERIF => array(FS_NORMAL =>'DejaVuSans.ttf', 320 FS_BOLD =>'DejaVuSans-Bold.ttf', 321 FS_ITALIC =>'DejaVuSans-Oblique.ttf', 322 FS_BOLDITALIC =>'DejaVuSans-BoldOblique.ttf' ), 323 324 FF_DV_SANSSERIFMONO => array(FS_NORMAL =>'DejaVuSansMono.ttf', 325 FS_BOLD =>'DejaVuSansMono-Bold.ttf', 326 FS_ITALIC =>'DejaVuSansMono-Oblique.ttf', 327 FS_BOLDITALIC =>'DejaVuSansMono-BoldOblique.ttf' ), 328 329 FF_DV_SANSSERIFCOND => array(FS_NORMAL =>'DejaVuSansCondensed.ttf', 330 FS_BOLD =>'DejaVuSansCondensed-Bold.ttf', 331 FS_ITALIC =>'DejaVuSansCondensed-Oblique.ttf', 332 FS_BOLDITALIC =>'DejaVuSansCondensed-BoldOblique.ttf' ), 333 334 FF_DV_SERIF => array(FS_NORMAL =>'DejaVuSerif.ttf', 335 FS_BOLD =>'DejaVuSerif-Bold.ttf', 336 FS_ITALIC =>'DejaVuSerif-Italic.ttf', 337 FS_BOLDITALIC =>'DejaVuSerif-BoldItalic.ttf' ), 338 339 FF_DV_SERIFCOND => array(FS_NORMAL =>'DejaVuSerifCondensed.ttf', 340 FS_BOLD =>'DejaVuSerifCondensed-Bold.ttf', 341 FS_ITALIC =>'DejaVuSerifCondensed-Italic.ttf', 342 FS_BOLDITALIC =>'DejaVuSerifCondensed-BoldItalic.ttf' ), 343 344 345 /* User defined font */ 346 FF_USERFONT1 => array(FS_NORMAL =>'', 347 FS_BOLD =>'', 348 FS_ITALIC =>'', 349 FS_BOLDITALIC =>'' ), 350 351 FF_USERFONT2 => array(FS_NORMAL =>'', 352 FS_BOLD =>'', 353 FS_ITALIC =>'', 354 FS_BOLDITALIC =>'' ), 355 356 FF_USERFONT3 => array(FS_NORMAL =>'', 357 FS_BOLD =>'', 358 FS_ITALIC =>'', 359 FS_BOLDITALIC =>'' ), 360 361 ); 362 } 363 364 //--------------- 365 // PUBLIC METHODS 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 366 467 // Create the TTF file from the font specification 367 468 function File($family,$style=FS_NORMAL) { 368 $fam = @$this->font_files[$family]; 369 if( !$fam ) { 370 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/"); 371 } 372 $f = @$fam[$style]; 373 374 if( $f==='' ) 375 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].'.'); 376 if( !$f ) { 377 JpGraphError::RaiseL(25048,$fam);//("Unknown font style specification [$fam]."); 378 } 379 380 if ($family >= FF_MINCHO && $family <= FF_PGOTHIC) { 381 $f = MBTTF_DIR.$f; 382 } else { 383 $f = TTF_DIR.$f; 384 } 385 386 if( file_exists($f) === false || is_readable($f) === false ) { 387 JpGraphError::RaiseL(25049,$f);//("Font file \"$f\" is not readable or does not exist."); 388 } 389 return $f; 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; 390 515 } 391 516 392 517 function SetUserFont($aNormal,$aBold='',$aItalic='',$aBoldIt='') { 393 $this->font_files[FF_USERFONT] = 394 array(FS_NORMAL => $aNormal, 395 FS_BOLD => $aBold, 396 FS_ITALIC => $aItalic, 397 FS_BOLDITALIC=> $aBoldIt ) ;518 $this->font_files[FF_USERFONT] = 519 array(FS_NORMAL => $aNormal, 520 FS_BOLD => $aBold, 521 FS_ITALIC => $aItalic, 522 FS_BOLDITALIC => $aBoldIt ) ; 398 523 } 399 524 400 525 function SetUserFont1($aNormal,$aBold='',$aItalic='',$aBoldIt='') { 401 $this->font_files[FF_USERFONT1] = 402 array(FS_NORMAL => $aNormal, 403 FS_BOLD => $aBold, 404 FS_ITALIC => $aItalic, 405 FS_BOLDITALIC=> $aBoldIt ) ;526 $this->font_files[FF_USERFONT1] = 527 array(FS_NORMAL => $aNormal, 528 FS_BOLD => $aBold, 529 FS_ITALIC => $aItalic, 530 FS_BOLDITALIC => $aBoldIt ) ; 406 531 } 407 532 408 533 function SetUserFont2($aNormal,$aBold='',$aItalic='',$aBoldIt='') { 409 $this->font_files[FF_USERFONT2] = 410 array(FS_NORMAL => $aNormal, 411 FS_BOLD => $aBold, 412 FS_ITALIC => $aItalic, 413 FS_BOLDITALIC=> $aBoldIt ) ;534 $this->font_files[FF_USERFONT2] = 535 array(FS_NORMAL => $aNormal, 536 FS_BOLD => $aBold, 537 FS_ITALIC => $aItalic, 538 FS_BOLDITALIC => $aBoldIt ) ; 414 539 } 415 540 416 541 function SetUserFont3($aNormal,$aBold='',$aItalic='',$aBoldIt='') { 417 $this->font_files[FF_USERFONT3] = 418 array(FS_NORMAL => $aNormal, 419 FS_BOLD => $aBold, 420 FS_ITALIC => $aItalic, 421 FS_BOLDITALIC=> $aBoldIt ) ;542 $this->font_files[FF_USERFONT3] = 543 array(FS_NORMAL => $aNormal, 544 FS_BOLD => $aBold, 545 FS_ITALIC => $aItalic, 546 FS_BOLDITALIC => $aBoldIt ) ; 422 547 } 423 548 … … 425 550 426 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 //============================================================================= 558 class 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 427 630 428 631 ?>
Note:
See TracChangeset
for help on using the changeset viewer.