Install zendframework via composer, update build.xml and run, updates to composer
[openemr.git] / vendor / phenx / php-font-lib / src / FontLib / TrueType / Collection.php
blob460ef4dae3e21f71c7d0be970c1be53a077591fc
1 <?php
2 /**
3 * @package php-font-lib
4 * @link https://github.com/PhenX/php-font-lib
5 * @author Fabien Ménager <fabien.menager@gmail.com>
6 * @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License
7 */
9 namespace FontLib\TrueType;
11 use Countable;
12 use FontLib\BinaryStream;
13 use Iterator;
14 use OutOfBoundsException;
16 /**
17 * TrueType collection font file.
19 * @package php-font-lib
21 class Collection extends BinaryStream implements Iterator, Countable {
22 /**
23 * Current iterator position.
25 * @var integer
27 private $position = 0;
29 protected $collectionOffsets = array();
30 protected $collection = array();
31 protected $version;
32 protected $numFonts;
34 function parse() {
35 if (isset($this->numFonts)) {
36 return;
39 $this->read(4); // tag name
41 $this->version = $this->readFixed();
42 $this->numFonts = $this->readUInt32();
44 for ($i = 0; $i < $this->numFonts; $i++) {
45 $this->collectionOffsets[] = $this->readUInt32();
49 /**
50 * @param int $fontId
52 * @throws OutOfBoundsException
53 * @return File
55 function getFont($fontId) {
56 $this->parse();
58 if (!isset($this->collectionOffsets[$fontId])) {
59 throw new OutOfBoundsException();
62 if (isset($this->collection[$fontId])) {
63 return $this->collection[$fontId];
66 $font = new File();
67 $font->f = $this->f;
68 $font->setTableOffset($this->collectionOffsets[$fontId]);
70 return $this->collection[$fontId] = $font;
73 function current() {
74 return $this->getFont($this->position);
77 function key() {
78 return $this->position;
81 function next() {
82 return ++$this->position;
85 function rewind() {
86 $this->position = 0;
89 function valid() {
90 $this->parse();
92 return isset($this->collectionOffsets[$this->position]);
95 function count() {
96 $this->parse();
98 return $this->numFonts;