PluginProbe
Yatra – Travel Booking & Tour Operator Software / 3.0.16
Yatra – Travel Booking & Tour Operator Software v3.0.16
3.0.16 3.0.15 3.0.14 3.0.14.1 3.0.14.2 3.0.12 3.0.13 3.0.11 3.0.10 3.0.9 3.0.8 3.0.7 3.0.6 3.0.5 3.0.5.1 3.0.4 3.0.3 3.0.2.9 3.0.2.7 3.0.2.8 3.0.2.6 trunk 1.0.0 2.0.0 2.0.1 All 84 releases
yatra / vendor / phenx / php-font-lib / src / FontLib / Table / DirectoryEntry.php

DirectoryEntry.php in Yatra – Travel Booking & Tour Operator Software 3.0.16, at vendor/phenx/php-font-lib/src/FontLib/Table/DirectoryEntry.php

131 lines 2.4 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 * @author Fabien Ménager <[email protected]>
6 * @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License
7 */
8 namespace FontLib\Table;
9
10 use FontLib\TrueType\File;
11 use FontLib\Font;
12 use FontLib\BinaryStream;
13
14 /**
15 * Generic Font table directory entry.
16 *
17 * @package php-font-lib
18 */
19 class DirectoryEntry extends BinaryStream {
20 /**
21 * @var File
22 */
23 protected $font;
24
25 /**
26 * @var Table
27 */
28 protected $font_table;
29
30 public $entryLength = 4;
31
32 public $tag;
33 public $checksum;
34 public $offset;
35 public $length;
36
37 protected $origF;
38
39 /**
40 * @param string $data
41 *
42 * @return int
43 */
44 static function computeChecksum($data) {
45 $len = mb_strlen($data, '8bit');
46 $mod = $len % 4;
47
48 if ($mod) {
49 $data = str_pad($data, $len + (4 - $mod), "\0");
50 }
51
52 $table = unpack("N*", $data);
53 return array_sum($table);
54 }
55
56 function __construct(File $font) {
57 $this->font = $font;
58 $this->f = $font->f;
59 }
60
61 function parse() {
62 $this->tag = $this->font->read(4);
63 }
64
65 function open($filename, $mode = self::modeRead) {
66 // void
67 }
68
69 function setTable(Table $font_table) {
70 $this->font_table = $font_table;
71 }
72
73 function encode($entry_offset) {
74 Font::d("\n==== $this->tag ====");
75 //Font::d("Entry offset = $entry_offset");
76
77 $data = $this->font_table;
78 $font = $this->font;
79
80 $table_offset = $font->pos();
81 $this->offset = $table_offset;
82 $table_length = $data->encode();
83
84 $font->seek($table_offset + $table_length);
85 $pad = 0;
86 $mod = $table_length % 4;
87 if ($mod != 0) {
88 $pad = 4 - $mod;
89 $font->write(str_pad("", $pad, "\0"), $pad);
90 }
91
92 $font->seek($table_offset);
93 $table_data = $font->read($table_length);
94
95 $font->seek($entry_offset);
96
97 $font->write($this->tag, 4);
98 $font->writeUInt32(self::computeChecksum($table_data));
99 $font->writeUInt32($table_offset);
100 $font->writeUInt32($table_length);
101
102 Font::d("Bytes written = $table_length");
103
104 $font->seek($table_offset + $table_length + $pad);
105 }
106
107 /**
108 * @return File
109 */
110 function getFont() {
111 return $this->font;
112 }
113
114 function startRead() {
115 $this->font->seek($this->offset);
116 }
117
118 function endRead() {
119 //
120 }
121
122 function startWrite() {
123 $this->font->seek($this->offset);
124 }
125
126 function endWrite() {
127 //
128 }
129 }
130
131