Example #1
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));
     $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 $tag => $entry) {
         $entry->encode($directory_offset + $i * $n);
         $i++;
     }
 }
 function parseHeader()
 {
     if (!empty($this->header)) {
         return;
     }
     $this->seek($this->tableOffset);
     $this->header = new Font_TrueType_Header($this);
     $this->header->parse();
 }