PluginProbe
Easy Invoice – Invoice Generator, PDF Quotes & Payments / 2.4.2
Easy Invoice – Invoice Generator, PDF Quotes & Payments v2.4.2
2.4.3 2.4.4 2.4.2 2.4.0 2.4.1 2.3.8 2.3.7 2.3.6 2.3.5 2.3.4 2.3.3 2.3.2 2.3.1 2.2.0 2.1.21 2.1.20 2.1.19 2.1.18 2.1.0 2.1.1 2.1.10 2.1.11 2.1.12 2.1.13 2.1.14 All 60 releases
easy-invoice / vendor / dompdf / php-font-lib / src / FontLib / Font.php

Font.php in Easy Invoice – Invoice Generator, PDF Quotes & Payments 2.4.2, at vendor/dompdf/php-font-lib/src/FontLib/Font.php

89 lines 1.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * @package php-font-lib
4 * @link https://github.com/dompdf/php-font-lib
5 * @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License
6 */
7
8 namespace FontLib;
9
10 use FontLib\Exception\FontNotFoundException;
11
12 /**
13 * Generic font file.
14 *
15 * @package php-font-lib
16 */
17 class Font {
18 static $debug = false;
19
20 /**
21 * @param string $file The font file
22 *
23 * @return TrueType\File|null $file
24 */
25 public static function load($file) {
26 if(!file_exists($file)){
27 throw new FontNotFoundException($file);
28 }
29
30 $header = file_get_contents($file, false, null, 0, 4);
31 $class = null;
32
33 switch ($header) {
34 case "\x00\x01\x00\x00":
35 case "true":
36 case "typ1":
37 $class = "TrueType\\File";
38 break;
39
40 case "OTTO":
41 $class = "OpenType\\File";
42 break;
43
44 case "wOFF":
45 $class = "WOFF\\File";
46 break;
47
48 case "ttcf":
49 $class = "TrueType\\Collection";
50 break;
51
52 // Unknown type or EOT
53 default:
54 $magicNumber = file_get_contents($file, false, null, 34, 2);
55
56 if ($magicNumber === "LP") {
57 $class = "EOT\\File";
58 }
59 }
60
61 if ($class) {
62 $class = "FontLib\\$class";
63
64 /** @var TrueType\File $obj */
65 $obj = new $class;
66 $obj->load($file);
67
68 return $obj;
69 }
70
71 return null;
72 }
73
74 static function d($str) {
75 if (!self::$debug) {
76 return;
77 }
78 echo "$str\n";
79 }
80
81 static function UTF16ToUTF8($str) {
82 return mb_convert_encoding($str, "utf-8", "utf-16");
83 }
84
85 static function UTF8ToUTF16($str) {
86 return mb_convert_encoding($str, "utf-16", "utf-8");
87 }
88 }
89