Font_Table_loca

`loca` font table.

Defined (1)

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

/lib/dompdf/lib/php-font-lib/classes/Font_Table_loca.php  
  1. class Font_Table_loca extends Font_Table { 
  2. protected function _parse() { 
  3. $font = $this->getFont(); 
  4. $offset = $font->pos(); 
  5.  
  6. $indexToLocFormat = $font->getData("head", "indexToLocFormat"); 
  7. $numGlyphs = $font->getData("maxp", "numGlyphs"); 
  8.  
  9. $font->seek($offset); 
  10.  
  11. $data = array(); 
  12.  
  13. // 2 bytes 
  14. if ($indexToLocFormat == 0) { 
  15. $d = $font->read(($numGlyphs + 1) * 2); 
  16. $loc = unpack("n*", $d); 
  17.  
  18. for ($i = 0; $i <= $numGlyphs; $i++) { 
  19. $data[] = $loc[$i+1] * 2; 
  20.  
  21. // 4 bytes 
  22. else if ($indexToLocFormat == 1) { 
  23. $d = $font->read(($numGlyphs + 1) * 4); 
  24. $loc = unpack("N*", $d); 
  25.  
  26. for ($i = 0; $i <= $numGlyphs; $i++) { 
  27. $data[] = $loc[$i+1]; 
  28.  
  29. $this->data = $data; 
  30.  
  31. function _encode() { 
  32. $font = $this->getFont(); 
  33. $data = $this->data; 
  34.  
  35. $indexToLocFormat = $font->getData("head", "indexToLocFormat"); 
  36. $numGlyphs = $font->getData("maxp", "numGlyphs"); 
  37. $length = 0; 
  38.  
  39. // 2 bytes 
  40. if ($indexToLocFormat == 0) { 
  41. for ($i = 0; $i <= $numGlyphs; $i++) { 
  42. $length += $font->writeUInt16($data[$i] / 2); 
  43.  
  44. // 4 bytes 
  45. else if ($indexToLocFormat == 1) { 
  46. for ($i = 0; $i <= $numGlyphs; $i++) { 
  47. $length += $font->writeUInt32($data[$i]); 
  48.  
  49. return $length;