| 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. |
| 15 |
* |
| 16 |
* @package php-font-lib |
| 17 |
*/ |
| 18 |
class Table extends BinaryStream |
| 19 |
{ |
| 20 |
/** |
| 21 |
* @var DirectoryEntry |
| 22 |
*/ |
| 23 |
protected $entry; |
| 24 |
protected $def = array(); |
| 25 |
public $data; |
| 26 |
public final function __construct(DirectoryEntry $entry) |
| 27 |
{ |
| 28 |
$this->entry = $entry; |
| 29 |
$entry->setTable($this); |
| 30 |
} |
| 31 |
/** |
| 32 |
* @return File |
| 33 |
*/ |
| 34 |
public function getFont() |
| 35 |
{ |
| 36 |
return $this->entry->getFont(); |
| 37 |
} |
| 38 |
protected function _encode() |
| 39 |
{ |
| 40 |
if (empty($this->data)) { |
| 41 |
Font::d(" >> Table is empty"); |
| 42 |
return 0; |
| 43 |
} |
| 44 |
return $this->getFont()->pack($this->def, $this->data); |
| 45 |
} |
| 46 |
protected function _parse() |
| 47 |
{ |
| 48 |
$this->data = $this->getFont()->unpack($this->def); |
| 49 |
} |
| 50 |
protected function _parseRaw() |
| 51 |
{ |
| 52 |
$this->data = $this->getFont()->read($this->entry->length); |
| 53 |
} |
| 54 |
protected function _encodeRaw() |
| 55 |
{ |
| 56 |
return $this->getFont()->write($this->data, $this->entry->length); |
| 57 |
} |
| 58 |
public function toHTML() |
| 59 |
{ |
| 60 |
return "<pre>" . \var_export($this->data, \true) . "</pre>"; |
| 61 |
} |
| 62 |
public final function encode() |
| 63 |
{ |
| 64 |
$this->entry->startWrite(); |
| 65 |
if (\false && empty($this->def)) { |
| 66 |
$length = $this->_encodeRaw(); |
| 67 |
} else { |
| 68 |
$length = $this->_encode(); |
| 69 |
} |
| 70 |
$this->entry->endWrite(); |
| 71 |
return $length; |
| 72 |
} |
| 73 |
public final function parse() |
| 74 |
{ |
| 75 |
$this->entry->startRead(); |
| 76 |
if (\false && empty($this->def)) { |
| 77 |
$this->_parseRaw(); |
| 78 |
} else { |
| 79 |
$this->_parse(); |
| 80 |
} |
| 81 |
$this->entry->endRead(); |
| 82 |
} |
| 83 |
} |
| 84 |
|