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
9 namespace FontLib\Table\Type;
10 use FontLib\Table\Table;
15 * @package php-font-lib
17 class loca extends Table {
18 protected function _parse() {
19 $font = $this->getFont();
20 $offset = $font->pos();
22 $indexToLocFormat = $font->getData("head", "indexToLocFormat");
23 $numGlyphs = $font->getData("maxp", "numGlyphs");
30 if ($indexToLocFormat == 0) {
31 $d = $font->read(($numGlyphs + 1) * 2);
32 $loc = unpack("n*", $d);
34 for ($i = 0; $i <= $numGlyphs; $i++) {
35 $data[] = $loc[$i + 1] * 2;
41 if ($indexToLocFormat == 1) {
42 $d = $font->read(($numGlyphs + 1) * 4);
43 $loc = unpack("N*", $d);
45 for ($i = 0; $i <= $numGlyphs; $i++) {
46 $data[] = $loc[$i + 1];
55 $font = $this->getFont();
58 $indexToLocFormat = $font->getData("head", "indexToLocFormat");
59 $numGlyphs = $font->getData("maxp", "numGlyphs");
63 if ($indexToLocFormat == 0) {
64 for ($i = 0; $i <= $numGlyphs; $i++) {
65 $length += $font->writeUInt16($data[$i] / 2);
71 if ($indexToLocFormat == 1) {
72 for ($i = 0; $i <= $numGlyphs; $i++) {
73 $length += $font->writeUInt32($data[$i]);