Ejemplo n.º 1
0
 protected function _encode()
 {
     if (empty($this->data)) {
         Font::d("  >> Table is empty");
         return 0;
     }
     return $this->getFont()->pack($this->def, $this->data);
 }
Ejemplo n.º 2
0
 function encode($entry_offset)
 {
     Font::d("\n==== {$this->tag} ====");
     //Font::d("Entry offset  = $entry_offset");
     $data = $this->font_table;
     $font = $this->font;
     $table_offset = $font->pos();
     $this->offset = $table_offset;
     $table_length = $data->encode();
     $font->seek($table_offset);
     $table_data = $font->read($table_length);
     $font->seek($entry_offset);
     $font->write($this->tag, 4);
     $font->writeUInt32(self::computeChecksum($table_data));
     $font->writeUInt32($table_offset);
     $font->writeUInt32($table_length);
     Font::d("Bytes written = {$table_length}");
     $font->seek($table_offset + $table_length);
 }
Ejemplo n.º 3
0
 function encode($tags = array())
 {
     if (!self::$raw) {
         $tags = array_merge(array("head", "hhea", "cmap", "hmtx", "maxp", "glyf", "loca", "name", "post"), $tags);
     } else {
         $tags = array_keys($this->directory);
     }
     $num_tables = count($tags);
     $n = 16;
     // @todo
     Font::d("Tables : " . implode(", ", $tags));
     /** @var DirectoryEntry[] $entries */
     $entries = array();
     foreach ($tags as $tag) {
         if (!isset($this->directory[$tag])) {
             Font::d("  >> '{$tag}' table doesn't exist");
             continue;
         }
         $entries[$tag] = $this->directory[$tag];
     }
     $this->header->data["numTables"] = $num_tables;
     $this->header->encode();
     $directory_offset = $this->pos();
     $offset = $directory_offset + $num_tables * $n;
     $this->seek($offset);
     $i = 0;
     foreach ($entries as $entry) {
         $entry->encode($directory_offset + $i * $n);
         $i++;
     }
 }