3 * @package php-font-lib
4 * @link https://github.com/PhenX/php-font-lib
5 * @author Fabien Ménager <fabien.menager@gmail.com>
6 * @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License
8 namespace FontLib\Table;
10 use FontLib\TrueType\File;
12 use FontLib\BinaryStream;
17 * @package php-font-lib
19 class Table extends BinaryStream {
24 protected $def = array();
28 final public function __construct(DirectoryEntry $entry) {
29 $this->entry = $entry;
30 $entry->setTable($this);
36 public function getFont() {
37 return $this->entry->getFont();
40 protected function _encode() {
41 if (empty($this->data)) {
42 Font::d(" >> Table is empty");
47 return $this->getFont()->pack($this->def, $this->data);
50 protected function _parse() {
51 $this->data = $this->getFont()->unpack($this->def);
54 protected function _parseRaw() {
55 $this->data = $this->getFont()->read($this->entry->length);
58 protected function _encodeRaw() {
59 return $this->getFont()->write($this->data, $this->entry->length);
62 public function toHTML() {
63 return "<pre>" . var_export($this->data, true) . "</pre>";
66 final public function encode() {
67 $this->entry->startWrite();
69 if (false && empty($this->def)) {
70 $length = $this->_encodeRaw();
73 $length = $this->_encode();
76 $this->entry->endWrite();
81 final public function parse() {
82 $this->entry->startRead();
84 if (false && empty($this->def)) {
91 $this->entry->endRead();