Font_Table_hmtx

`hmtx` font table.

Defined (1)

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

/lib/dompdf/lib/php-font-lib/classes/Font_Table_hmtx.php  
  1. class Font_Table_hmtx extends Font_Table { 
  2. protected function _parse() { 
  3. $font = $this->getFont(); 
  4. $offset = $font->pos(); 
  5.  
  6. $numOfLongHorMetrics = $font->getData("hhea", "numOfLongHorMetrics"); 
  7. $numGlyphs = $font->getData("maxp", "numGlyphs"); 
  8.  
  9. $font->seek($offset); 
  10.  
  11. $data = array(); 
  12. for($gid = 0; $gid < $numOfLongHorMetrics; $gid++) { 
  13. $advanceWidth = $font->readUInt16(); 
  14. $leftSideBearing = $font->readUInt16(); 
  15. $data[$gid] = array($advanceWidth, $leftSideBearing); 
  16.  
  17. if($numOfLongHorMetrics < $numGlyphs) { 
  18. $lastWidth = end($data); 
  19. $data = array_pad($data, $numGlyphs, $lastWidth); 
  20.  
  21. $this->data = $data; 
  22.  
  23. protected function _encode() { 
  24. $font = $this->getFont(); 
  25. $subset = $font->getSubset(); 
  26. $data = $this->data; 
  27.  
  28. $length = 0; 
  29.  
  30. foreach($subset as $gid) { 
  31. $length += $font->writeUInt16($data[$gid][0]); 
  32. $length += $font->writeUInt16($data[$gid][1]); 
  33.  
  34. return $length;