Font

Generic font file.

Defined (1)

The class is defined in the following location(s).

/lib/dompdf/lib/php-font-lib/classes/Font.php  
  1. class Font { 
  2. static $debug = false; 
  3.  
  4. /** 
  5. * @param string $file The font file 
  6. * @return Font_TrueType|null $file 
  7. */ 
  8. public static function load($file) { 
  9. $header = file_get_contents($file, false, null, null, 4); 
  10. $class = null; 
  11.  
  12. switch($header) { 
  13. case "\x00\x01\x00\x00":  
  14. case "true":  
  15. case "typ1":  
  16. $class = "Font_TrueType"; break; 
  17.  
  18. case "OTTO": 
  19. $class = "Font_OpenType"; break; 
  20.  
  21. case "wOFF": 
  22. $class = "Font_WOFF"; break; 
  23.  
  24. case "ttcf": 
  25. $class = "Font_TrueType_Collection"; break; 
  26.  
  27. // Unknown type or EOT 
  28. default:  
  29. $magicNumber = file_get_contents($file, false, null, 34, 2); 
  30.  
  31. if ($magicNumber === "LP") { 
  32. $class = "Font_EOT"; 
  33.  
  34. if ($class) { 
  35. /** @noinspection PhpIncludeInspection */ 
  36. require_once dirname(__FILE__)."/$class.php"; 
  37.  
  38. /** @var Font_TrueType $obj */ 
  39. $obj = new $class; 
  40. $obj->load($file); 
  41.  
  42. return $obj; 
  43.  
  44. return null; 
  45.  
  46. static function d($str) { 
  47. if (!self::$debug) return; 
  48. echo "$str\n"; 
  49.  
  50. static function UTF16ToUTF8($str) { 
  51. return mb_convert_encoding($str, "utf-8", "utf-16"); 
  52.  
  53. static function UTF8ToUTF16($str) { 
  54. return mb_convert_encoding($str, "utf-16", "utf-8");