function parseData() { parent::parseData(); $font = $this->getFont(); do { $flags = $font->readUInt16(); $glyphIndex = $font->readUInt16(); $a = 1.0; $b = 0.0; $c = 0.0; $d = 1.0; $e = 0.0; $f = 0.0; $point_compound = null; $point_component = null; $instructions = null; if ($flags & self::ARG_1_AND_2_ARE_WORDS) { if ($flags & self::ARGS_ARE_XY_VALUES) { $e = $font->readInt16(); $f = $font->readInt16(); } else { $point_compound = $font->readUInt16(); $point_component = $font->readUInt16(); } } else { if ($flags & self::ARGS_ARE_XY_VALUES) { $e = $font->readInt8(); $f = $font->readInt8(); } else { $point_compound = $font->readUInt8(); $point_component = $font->readUInt8(); } } if ($flags & self::WE_HAVE_A_SCALE) { $a = $d = $font->readInt16(); } elseif ($flags & self::WE_HAVE_AN_X_AND_Y_SCALE) { $a = $font->readInt16(); $d = $font->readInt16(); } elseif ($flags & self::WE_HAVE_A_TWO_BY_TWO) { $a = $font->readInt16(); $b = $font->readInt16(); $c = $font->readInt16(); $d = $font->readInt16(); } //if ($flags & self::WE_HAVE_INSTRUCTIONS) { // //} $component = new OutlineComponent(); $component->flags = $flags; $component->glyphIndex = $glyphIndex; $component->a = $a; $component->b = $b; $component->c = $c; $component->d = $d; $component->e = $e; $component->f = $f; $component->point_compound = $point_compound; $component->point_component = $point_component; $component->instructions = $instructions; $this->components[] = $component; } while ($flags & self::MORE_COMPONENTS); }
function parseData() { parent::parseData(); if (!$this->size) { return; } $font = $this->getFont(); $noc = $this->numberOfContours; if ($noc == 0) { return; } $endPtsOfContours = $font->r(array(self::uint16, $noc)); $instructionLength = $font->readUInt16(); $this->instructions = $font->r(array(self::uint8, $instructionLength)); $count = $endPtsOfContours[$noc - 1] + 1; // Flags $flags = array(); for ($index = 0; $index < $count; $index++) { $flags[$index] = $font->readUInt8(); if ($flags[$index] & self::REPEAT) { $repeats = $font->readUInt8(); for ($i = 1; $i <= $repeats; $i++) { $flags[$index + $i] = $flags[$index]; } $index += $repeats; } } $points = array(); foreach ($flags as $i => $flag) { $points[$i]["onCurve"] = $flag & self::ON_CURVE; $points[$i]["endOfContour"] = in_array($i, $endPtsOfContours); } // X Coords $x = 0; for ($i = 0; $i < $count; $i++) { $flag = $flags[$i]; if ($flag & self::THIS_X_IS_SAME) { if ($flag & self::X_SHORT_VECTOR) { $x += $font->readUInt8(); } } else { if ($flag & self::X_SHORT_VECTOR) { $x -= $font->readUInt8(); } else { $x += $font->readInt16(); } } $points[$i]["x"] = $x; } // Y Coords $y = 0; for ($i = 0; $i < $count; $i++) { $flag = $flags[$i]; if ($flag & self::THIS_Y_IS_SAME) { if ($flag & self::Y_SHORT_VECTOR) { $y += $font->readUInt8(); } } else { if ($flag & self::Y_SHORT_VECTOR) { $y -= $font->readUInt8(); } else { $y += $font->readInt16(); } } $points[$i]["y"] = $y; } $this->points = $points; }