PluginProbe
Easy Invoice – Invoice Generator, PDF Quotes & Payments / 2.4.3
Easy Invoice – Invoice Generator, PDF Quotes & Payments v2.4.3
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 / WOFF / File.php

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

81 lines 1.9 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\WOFF;
9
10 use FontLib\Table\DirectoryEntry;
11
12 /**
13 * WOFF font file.
14 *
15 * @package php-font-lib
16 *
17 * @property TableDirectoryEntry[] $directory
18 */
19 class File extends \FontLib\TrueType\File {
20 function parseHeader() {
21 if (!empty($this->header)) {
22 return;
23 }
24
25 $this->header = new Header($this);
26 $this->header->parse();
27 }
28
29 public function load($file) {
30 parent::load($file);
31
32 $this->parseTableEntries();
33 $dataOffset = $this->pos() + count($this->directory) * 20;
34
35 $fw = $this->getTempFile(false);
36 $fr = $this->f;
37
38 $this->f = $fw;
39 $offset = $this->header->encode();
40
41 foreach ($this->directory as $entry) {
42 // Read ...
43 $this->f = $fr;
44 $this->seek($entry->offset);
45 $data = $this->read($entry->length);
46
47 if ($entry->length < $entry->origLength) {
48 $data = (string) gzuncompress($data);
49 }
50
51 // Prepare data ...
52 $length = mb_strlen($data, '8bit');
53 $entry->length = $entry->origLength = $length;
54 $entry->offset = $dataOffset;
55
56 // Write ...
57 $this->f = $fw;
58
59 // Woff Entry
60 $this->seek($offset);
61 $offset += $this->write($entry->tag, 4); // tag
62 $offset += $this->writeUInt32($dataOffset); // offset
63 $offset += $this->writeUInt32($length); // length
64 $offset += $this->writeUInt32($length); // origLength
65 $offset += $this->writeUInt32(DirectoryEntry::computeChecksum($data)); // checksum
66
67 // Data
68 $this->seek($dataOffset);
69 $dataOffset += $this->write($data, $length);
70 }
71
72 $this->f = $fw;
73 $this->seek(0);
74
75 // Need to re-parse this, don't know why
76 $this->header = null;
77 $this->directory = array();
78 $this->parseTableEntries();
79 }
80 }
81