3 * @package php-font-lib
4 * @link https://github.com/PhenX/php-font-lib
5 * @author Fabien Ménager <fabien.menager@gmail.com>
6 * @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License
11 use FontLib\Exception\FontNotFoundException;
16 * @package php-font-lib
19 static $debug = false;
22 * @param string $file The font file
24 * @return TrueType\File|null $file
26 public static function load($file) {
27 if(!file_exists($file)){
28 throw new FontNotFoundException($file);
31 $header = file_get_contents($file, false, null, null, 4);
35 case "\x00\x01\x00\x00":
38 $class = "TrueType\\File";
42 $class = "OpenType\\File";
46 $class = "WOFF\\File";
50 $class = "TrueType\\Collection";
53 // Unknown type or EOT
55 $magicNumber = file_get_contents($file, false, null, 34, 2);
57 if ($magicNumber === "LP") {
63 $class = "FontLib\\$class";
65 /** @var TrueType\File $obj */
75 static function d($str) {
82 static function UTF16ToUTF8($str) {
83 return mb_convert_encoding($str, "utf-8", "utf-16");
86 static function UTF8ToUTF16($str) {
87 return mb_convert_encoding($str, "utf-16", "utf-8");