Font_TrueType_Collection

TrueType collection font file.

Defined (1)

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

/lib/dompdf/lib/php-font-lib/classes/Font_TrueType_Collection.php  
  1. class Font_TrueType_Collection extends Font_Binary_Stream implements Iterator, Countable { 
  2. /** 
  3. * Current iterator position. 
  4. *  
  5. * @var integer 
  6. */ 
  7. private $position = 0; 
  8.  
  9. protected $collectionOffsets = array(); 
  10. protected $collection = array(); 
  11. protected $version; 
  12. protected $numFonts; 
  13.  
  14. function parse() { 
  15. if (isset($this->numFonts)) { 
  16. return; 
  17.  
  18. $this->read(4); // tag name 
  19.  
  20. $this->version = $this->readFixed(); 
  21. $this->numFonts = $this->readUInt32(); 
  22.  
  23. for ($i = 0; $i < $this->numFonts; $i++) { 
  24. $this->collectionOffsets[] = $this->readUInt32(); 
  25.  
  26. /** 
  27. * @param int $fontId 
  28. * @throws OutOfBoundsException 
  29. * @return Font_TrueType 
  30. */ 
  31. function getFont($fontId) { 
  32. $this->parse(); 
  33.  
  34. if (!isset($this->collectionOffsets[$fontId])) { 
  35. throw new OutOfBoundsException(); 
  36.  
  37. if (isset($this->collection[$fontId])) { 
  38. return $this->collection[$fontId]; 
  39.  
  40. $font = new Font_TrueType(); 
  41. $font->f = $this->f; 
  42. $font->setTableOffset($this->collectionOffsets[$fontId]); 
  43.  
  44. return $this->collection[$fontId] = $font; 
  45.  
  46. function current() { 
  47. return $this->getFont($this->position); 
  48.  
  49. function key() { 
  50. return $this->position; 
  51.  
  52. function next() { 
  53. return ++$this->position; 
  54.  
  55. function rewind() { 
  56. $this->position = 0; 
  57.  
  58. function valid() { 
  59. $this->parse(); 
  60. return isset($this->collectionOffsets[$this->position]); 
  61.  
  62. function count() { 
  63. $this->parse(); 
  64. return $this->numFonts;