Font_WOFF

WOFF font file.

Defined (1)

The class is defined in the following location(s).

/lib/dompdf/lib/php-font-lib/classes/Font_WOFF.php  
  1. class Font_WOFF extends Font_TrueType { 
  2. function parseHeader() { 
  3. if (!empty($this->header)) { 
  4. return; 
  5.  
  6. $this->header = new Font_WOFF_Header($this); 
  7. $this->header->parse(); 
  8.  
  9. public function load($file) { 
  10. parent::load($file); 
  11.  
  12. $this->parseTableEntries(); 
  13. $dataOffset = $this->pos() + count($this->directory) * 20; 
  14.  
  15. $fw = $this->getTempFile(false); 
  16. $fr = $this->f; 
  17.  
  18. $this->f = $fw; 
  19. $offset = $this->header->encode(); 
  20.  
  21. foreach($this->directory as $entry) { 
  22. // Read ... 
  23. $this->f = $fr; 
  24. $this->seek($entry->offset); 
  25. $data = $this->read($entry->length); 
  26.  
  27. if ($entry->length < $entry->origLength) { 
  28. $data = gzuncompress($data); 
  29.  
  30. // Prepare data ... 
  31. $length = strlen($data); 
  32. $entry->length = $entry->origLength = $length; 
  33. $entry->offset = $dataOffset; 
  34.  
  35. // Write ... 
  36. $this->f = $fw; 
  37.  
  38. // Woff Entry  
  39. $this->seek($offset); 
  40. $offset += $this->write($entry->tag, 4); // tag 
  41. $offset += $this->writeUInt32($dataOffset); // offset 
  42. $offset += $this->writeUInt32($length); // length 
  43. $offset += $this->writeUInt32($length); // origLength 
  44. $offset += $this->writeUInt32(Font_Table_Directory_Entry::computeChecksum($data)); // checksum 
  45.  
  46. // Data 
  47. $this->seek($dataOffset); 
  48. $dataOffset += $this->write($data, $length); 
  49.  
  50. $this->f = $fw; 
  51. $this->seek(0); 
  52.  
  53. // Need to re-parse this, don't know why 
  54. $this->header = null; 
  55. $this->directory = array(); 
  56. $this->parseTableEntries();