PluginProbe
WCPOS – Point of Sale (POS) plugin for WooCommerce / 1.10.2
WCPOS – Point of Sale (POS) plugin for WooCommerce v1.10.2
1.10.19 1.10.18 1.10.17 1.10.16 1.10.15 1.10.13 1.10.14 1.10.12 1.10.11 1.10.10 1.10.9 1.10.8 untagged-3d9b7ccddc54df87c672 1.10.7 1.10.6 1.10.5 1.10.3 1.10.4 1.10.2 1.10.1 1.10.0 1.9.17 1.9.15 1.9.16 1.9.14 All 163 releases
woocommerce-pos / vendor_prefixed / dompdf / php-font-lib / src / FontLib / Table / DirectoryEntry.php

DirectoryEntry.php in WCPOS – Point of Sale (POS) plugin for WooCommerce 1.10.2, at vendor_prefixed/dompdf/php-font-lib/src/FontLib/Table/DirectoryEntry.php

116 lines 2.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * @package php-font-lib
5 * @link https://github.com/dompdf/php-font-lib
6 * @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License
7 */
8 namespace WCPOS\Vendor\FontLib\Table;
9
10 use WCPOS\Vendor\FontLib\TrueType\File;
11 use WCPOS\Vendor\FontLib\Font;
12 use WCPOS\Vendor\FontLib\BinaryStream;
13 /**
14 * Generic Font table directory entry.
15 *
16 * @package php-font-lib
17 */
18 class DirectoryEntry extends BinaryStream
19 {
20 /**
21 * @var File
22 */
23 protected $font;
24 /**
25 * @var Table
26 */
27 protected $font_table;
28 public $entryLength = 4;
29 public $tag;
30 public $checksum;
31 public $offset;
32 public $length;
33 protected $origF;
34 /**
35 * @param string $data
36 *
37 * @return int
38 */
39 static function computeChecksum($data)
40 {
41 $len = \mb_strlen($data, '8bit');
42 $mod = $len % 4;
43 if ($mod) {
44 $data = \str_pad($data, $len + (4 - $mod), "\x00");
45 }
46 $table = \unpack("N*", $data);
47 return \array_sum($table);
48 }
49 function __construct(File $font)
50 {
51 $this->font = $font;
52 $this->f = $font->f;
53 }
54 function parse()
55 {
56 $this->tag = $this->font->read(4);
57 }
58 function open($filename, $mode = self::modeRead)
59 {
60 // void
61 }
62 function setTable(Table $font_table)
63 {
64 $this->font_table = $font_table;
65 }
66 function encode($entry_offset)
67 {
68 Font::d("\n==== {$this->tag} ====");
69 //Font::d("Entry offset = $entry_offset");
70 $data = $this->font_table;
71 $font = $this->font;
72 $table_offset = $font->pos();
73 $this->offset = $table_offset;
74 $table_length = $data->encode();
75 $font->seek($table_offset + $table_length);
76 $pad = 0;
77 $mod = $table_length % 4;
78 if ($mod != 0) {
79 $pad = 4 - $mod;
80 $font->write(\str_pad("", $pad, "\x00"), $pad);
81 }
82 $font->seek($table_offset);
83 $table_data = $font->read($table_length);
84 $font->seek($entry_offset);
85 $font->write($this->tag, 4);
86 $font->writeUInt32(self::computeChecksum($table_data));
87 $font->writeUInt32($table_offset);
88 $font->writeUInt32($table_length);
89 Font::d("Bytes written = {$table_length}");
90 $font->seek($table_offset + $table_length + $pad);
91 }
92 /**
93 * @return File
94 */
95 function getFont()
96 {
97 return $this->font;
98 }
99 function startRead()
100 {
101 $this->font->seek($this->offset);
102 }
103 function endRead()
104 {
105 //
106 }
107 function startWrite()
108 {
109 $this->font->seek($this->offset);
110 }
111 function endWrite()
112 {
113 //
114 }
115 }
116