Example #1
0
 /**
  * Reads the information from the given stream.
  *
  * @param StreamInterface $stream The stream to read from.
  */
 public function read(StreamInterface $stream)
 {
     $this->bCharSet = $stream->readByte();
     $this->xRatio = $stream->readByte();
     $this->yStartRatio = $stream->readByte();
     $this->yEndRatio = $stream->readByte();
 }
Example #2
0
 /**
  * Reads the table from the given stream.
  *
  * @param StreamInterface $stream The stream to read from.
  */
 public function read(StreamInterface $stream)
 {
     $this->version = $stream->readFixed();
     $this->scriptList = $stream->readOffset();
     $this->featureList = $stream->readOffset();
     $this->lookupList = $stream->readOffset();
 }
Example #3
0
 /**
  * @param StreamInterface $stream The stream to read from.
  */
 public function read(StreamInterface $stream)
 {
     $this->version = $stream->readUShort();
     $this->numGlyphs = $stream->readUShort();
     $this->yPels = array();
     for ($i = 0; $i < $this->numGlyphs; ++$i) {
         $this->yPels[] = $stream->readChar();
     }
 }
Example #4
0
 /**
  * Reads the data from the given stream.
  *
  * @param StreamInterface $stream The stream to read from.
  */
 public function read(StreamInterface $stream)
 {
     // Read the format number...
     $stream->readUShort();
     $this->setLength($stream->readUShort());
     $this->setLanguage($stream->readUShort());
     for ($i = 0; $i < 256; ++$i) {
         $this->setGlyphId($i, $stream->readByte());
     }
 }
Example #5
0
 /**
  * Reads the information from the given stream.
  *
  * @param StreamInterface $stream The stream to read from.
  */
 public function read(StreamInterface $stream)
 {
     $this->recs = $stream->readUShort();
     $this->startsz = $stream->readByte();
     $this->endsz = $stream->readByte();
     $this->entry = array();
     for ($i = 0; $i < $this->recs; ++$i) {
         $record = new VTableRecord();
         $record->read($stream);
         $this->entry[] = $record;
     }
 }
Example #6
0
 /**
  * Reads the data from the given stream.
  *
  * @param StreamInterface $stream The stream to read from.
  */
 public function read(StreamInterface $stream)
 {
     // Read the format number...
     $stream->readUShort();
     $this->setLength($stream->readULong());
     $this->setNumVarSelectorRecords($stream->readULong());
     for ($i = 0; $i < $this->getNumVarSelectorRecords(); ++$i) {
         $record = new VarSelectorRecord();
         $record->read($stream);
         $this->varSelectorRecords[] = $record;
     }
     // TODO: Continue parsing this format.
     throw new RuntimeException(sprintf('CMAP format %d is not supported yet.', $this->getFormat()));
 }
Example #7
0
 /**
  * Reads the table from the given stream.
  *
  * @param StreamInterface $stream The stream to read from.
  */
 public function read(StreamInterface $stream)
 {
     $this->version = $stream->readUShort();
     $this->numRecs = $stream->readUShort();
     $this->numRatios = $stream->readUShort();
     $this->ratRange = array();
     for ($i = 0; $i < $this->numRatios; ++$i) {
         $record = new RatioRecord();
         $record->read($stream);
         $this->ratRange[] = $record;
     }
     $this->offset = array();
     for ($i = 0; $i < $this->numRatios; ++$i) {
         $this->offset[] = $stream->readUShort();
     }
     $this->groups = array();
     for ($i = 0; $i < $this->numRecs; ++$i) {
         $group = new VdmxGroup();
         $group->read($stream);
         $this->groups[] = $group;
     }
 }
Example #8
0
 /**
  * Reads the data from the given stream.
  *
  * @param StreamInterface $stream The stream to read from.
  */
 public function read(StreamInterface $stream)
 {
     // Read the format number...
     $stream->readUShort();
     $this->setLength($stream->readUShort());
     $this->setLanguage($stream->readUShort());
     $this->setFirstCode($stream->readUShort());
     $this->setEntryCount($stream->readUShort());
     for ($i = 0; $i < $this->getEntryCount(); ++$i) {
         $this->setGlyphId($i, $stream->readUShort());
     }
 }
Example #9
0
 /**
  * Reads the offset table from the given stream.
  *
  * @param StreamInterface $stream The stream to read from.
  */
 public function read(StreamInterface $stream)
 {
     $this->tag = $stream->readULong();
     $this->checksum = $stream->readULong();
     $this->offset = $stream->readULong();
     $this->length = $stream->readULong();
     $size = $stream->getSize();
     if ($this->offset < 0 || $this->offset > $size) {
         throw new \Exception('Table offset (' . $this->offset . ') not within expected range');
     }
     if ($this->length < 0 || $this->offset + $this->length > $size) {
         throw new \Exception('Table length (' . $this->length . ') not within expected range');
     }
 }
Example #10
0
 /**
  * Reads the header from the given stream.
  *
  * @param StreamInterface $stream The stream to read from.
  */
 public function read(StreamInterface $stream)
 {
     $this->sfntVersion = $stream->readFixed();
     $this->numTables = $stream->readUShort();
     $this->searchRange = $stream->readUShort();
     $this->entrySelector = $stream->readUShort();
     $this->rangeShift = $stream->readUShort();
 }
Example #11
0
 /**
  * Reads the table from the given stream.
  *
  * @param StreamInterface $stream The stream to read from.
  */
 public function read(StreamInterface $stream)
 {
     $this->version = $stream->readFixed();
     $this->numSizes = $stream->readULong();
 }
Example #12
0
 /**
  * Reads the information from the given stream.
  *
  * @param StreamInterface $stream The stream to read from.
  */
 public function read(StreamInterface $stream)
 {
     $this->yPelHeight = $stream->readUShort();
     $this->yMax = $stream->readShort();
     $this->yMin = $stream->readShort();
 }
Example #13
0
 /**
  * Reads information from the given stream.
  *
  * @param StreamInterface $stream The stream to read from.
  */
 public function read(StreamInterface $stream)
 {
     $this->tableVersionNumber = $stream->readFixed();
     $this->ascender = $stream->readFWord();
     $this->descender = $stream->readFWord();
     $this->lineGap = $stream->readFWord();
     $this->advanceWidthMax = $stream->readUFWord();
     $this->minLeftSideBearing = $stream->readFWord();
     $this->minRightSideBearing = $stream->readFWord();
     $this->xMaxExtent = $stream->readFWord();
     $this->caretSlopeRise = $stream->readShort();
     $this->caretSlopeRun = $stream->readShort();
     $this->caretOffset = $stream->readShort();
     // Read reserved values:
     $stream->readShort();
     $stream->readShort();
     $stream->readShort();
     $stream->readShort();
     $this->metricDataFormat = $stream->readShort();
     $this->numberOfHMetrics = $stream->readUShort();
 }
Example #14
0
 /**
  * Reads the table from the given stream.
  *
  * @param StreamInterface $stream The stream to read from.
  */
 public function read(StreamInterface $stream)
 {
     $this->version = $stream->readFixed();
 }
Example #15
0
 /**
  * Reads information from the given stream.
  *
  * @param StreamInterface $stream The stream to read from.
  */
 public function read(StreamInterface $stream)
 {
     $this->advanceWidth = $stream->readUShort();
     $this->lsb = $stream->readShort();
 }
Example #16
0
 /**
  * Reads information from the stream.
  *
  * @param StreamInterface $stream The stream to read from.
  */
 public function read(StreamInterface $stream)
 {
     $this->platformID = $stream->readUShort();
     $this->encodingID = $stream->readUShort();
     $this->languageID = $stream->readUShort();
     $this->nameID = $stream->readUShort();
     $this->length = $stream->readUShort();
     $this->offset = $stream->readUShort();
 }
Example #17
0
 /**
  * Reads information from the given stream.
  *
  * @param StreamInterface $stream The stream to read from.
  */
 public function read(StreamInterface $stream)
 {
     $this->length = $stream->readUShort();
     $this->offset = $stream->readUShort();
 }
Example #18
0
 /**
  * Reads the data from the given stream.
  *
  * @param StreamInterface $stream The stream to read from.
  */
 public function read(StreamInterface $stream)
 {
     // Read the format number...
     $stream->readUShort();
     $this->setLength($stream->readUShort());
     $this->setLanguage($stream->readUShort());
     $this->setSegCountX2($stream->readUShort());
     $this->setSearchRange($stream->readUShort());
     $this->setEntrySelector($stream->readUShort());
     $this->setRangeShift($stream->readUShort());
     $offset = 14;
     for ($i = 0; $i < $this->segCountX2 / 2; ++$i, $offset += 2) {
         $this->setEndCount($i, $stream->readUShort());
     }
     $this->setReservedPad($stream->readUShort());
     $offset += 2;
     for ($i = 0; $i < $this->segCountX2 / 2; ++$i, $offset += 2) {
         $this->setStartCount($i, $stream->readUShort());
     }
     for ($i = 0; $i < $this->segCountX2 / 2; ++$i, $offset += 2) {
         $this->setIdDelta($i, $stream->readShort());
     }
     for ($i = 0; $i < $this->segCountX2 / 2; ++$i, $offset += 2) {
         $this->setIdRangeOffset($i, $stream->readUShort());
     }
     for ($index = 0; $offset < $this->getLength(); $index++, $offset += 2) {
         $this->setGlyphId($index, $stream->readUShort());
     }
 }
Example #19
0
 /**
  * Reads the header from the given stream.
  *
  * @param StreamInterface $stream The stream to read from.
  */
 public function read(StreamInterface $stream)
 {
     $this->tag = $stream->readTag();
     if ($this->tag !== self::TTCF_ID) {
         throw new RuntimeException(sprintf('Invalid id provided, should be 0x%x but we got 0x%x', self::TTCF_ID, $this->tag));
     }
     $this->version = $stream->readFixed();
     $this->numFonts = $stream->readULong();
     for ($i = 0; $i < $this->numFonts; ++$i) {
         $this->offsetTable[] = $stream->readULong();
     }
     if ($this->version > 1) {
         $this->ulDsigTag = $stream->readULong();
         $this->ulDsigLength = $stream->readULong();
         $this->ulDsigOffset = $stream->readULong();
     }
 }
Example #20
0
 private function readSubtables(StreamInterface $stream)
 {
     foreach ($this->getEncodingRecords() as $encodingRecord) {
         $stream->setPosition($this->getBaseOffset() + $encodingRecord->getOffset());
         $format = $stream->readUShort();
         $stream->setPosition($this->getBaseOffset() + $encodingRecord->getOffset());
         $subTable = $this->getSubTable($format);
         $subTable->read($stream);
         $this->subTables[] = $subTable;
     }
 }
Example #21
0
 /**
  * @param StreamInterface $stream The stream to read from.
  */
 public function read(StreamInterface $stream)
 {
     $this->version = $stream->readUShort();
     $this->xAvgCharWidth = $stream->readShort();
     $this->usWeightClass = $stream->readUShort();
     $this->usWidthClass = $stream->readUShort();
     $this->fsType = $stream->readUShort();
     $this->ySubscriptXSize = $stream->readShort();
     $this->ySubscriptYSize = $stream->readShort();
     $this->ySubscriptXOffset = $stream->readShort();
     $this->ySubscriptYOffset = $stream->readShort();
     $this->ySuperscriptXSize = $stream->readShort();
     $this->ySuperscriptYSize = $stream->readShort();
     $this->ySuperscriptXOffset = $stream->readShort();
     $this->ySuperscriptYOffset = $stream->readShort();
     $this->yStrikeoutSize = $stream->readShort();
     $this->yStrikeoutPosition = $stream->readShort();
     $this->sFamilyClass = $stream->readShort();
     $this->panose = array();
     for ($i = 0; $i < 10; ++$i) {
         $this->panose[] = $stream->readByte();
     }
     $this->ulUnicodeRange1 = $stream->readULong();
     $this->ulUnicodeRange2 = $stream->readULong();
     $this->ulUnicodeRange3 = $stream->readULong();
     $this->ulUnicodeRange4 = $stream->readULong();
     $this->achVendID = array();
     for ($i = 0; $i < 4; ++$i) {
         $this->achVendID[] = $stream->readChar();
     }
     $this->fsSelection = $stream->readUShort();
     $this->usFirstCharIndex = $stream->readUShort();
     $this->usLastCharIndex = $stream->readUShort();
     $this->sTypoAscender = $stream->readShort();
     $this->sTypoDescender = $stream->readShort();
     $this->sTypoLineGap = $stream->readShort();
     $this->usWinAscent = $stream->readUShort();
     $this->usWinDescent = $stream->readUShort();
     $this->ulCodePageRange1 = $stream->readULong();
     $this->ulCodePageRange2 = $stream->readULong();
     $this->sxHeight = $stream->readShort();
     $this->sCapHeight = $stream->readShort();
     $this->usDefaultChar = $stream->readUShort();
     $this->usBreakChar = $stream->readUShort();
     $this->usMaxContext = $stream->readUShort();
 }
Example #22
0
 /**
  * Reads the DSIG table from the given stream.
  *
  * @param StreamInterface $stream The stream to read from.
  */
 public function read(StreamInterface $stream)
 {
     $this->ulVersion = $stream->readULong();
     $this->usNumSigs = $stream->readUShort();
     $this->usFlag = $stream->readUShort();
 }
Example #23
0
 /**
  * Reads the data from the given stream.
  *
  * @param StreamInterface $stream The stream to read from.
  */
 public function read(StreamInterface $stream)
 {
     $this->platformID = $stream->readUShort();
     $this->encodingID = $stream->readUShort();
     $this->offset = $stream->readULong();
 }
Example #24
0
 /**
  * Reads all the names from the given stream.
  *
  * @param StreamInterface $stream The stream to read from.
  * @return string[]
  */
 private function readNames(StreamInterface $stream)
 {
     $names = array();
     foreach ($this->nameRecord as $record) {
         // When there is no language code, we can't read the record name:
         if ($record->getLanguageCode() === null) {
             continue;
         }
         $stringOffset = $this->baseOffset + $this->stringOffset + $record->getOffset();
         $stream->setPosition($stringOffset);
         if ($record->getPlatformID() == 3) {
             $name = $stream->readStringBytes($record->getLength(), 'UTF-16BE', 'UTF-8');
         } else {
             $name = $stream->readStringBytes($record->getLength(), 'MacRoman', 'UTF-8');
         }
         $names[$record->getNameID()][$record->getLanguageCode()] = $name;
     }
     return $names;
 }
Example #25
0
 /**
  * @param StreamInterface $stream The stream to read from.
  */
 public function read(StreamInterface $stream)
 {
     $this->tableVersionNumber = $stream->readFixed();
     $this->fontRevision = $stream->readFixed();
     $this->checkSumAdjustment = $stream->readULong();
     $this->magicNumber = $stream->readULong();
     if ($this->magicNumber != self::MAGIC_NUMBER) {
         throw new \Exception(sprintf('Magic number for head table should be set to 0x%x but we got 0x%x', self::MAGIC_NUMBER, $this->magicNumber));
     }
     $this->flags = $stream->readUShort();
     $this->unitsPerEm = $stream->readUShort();
     $this->created = $stream->readLongDateTime();
     $this->modified = $stream->readLongDateTime();
     $this->xMin = $stream->readShort();
     $this->yMin = $stream->readShort();
     $this->xMax = $stream->readShort();
     $this->yMax = $stream->readShort();
     $this->macStyle = $stream->readUShort();
     $this->lowestRecPPEM = $stream->readUShort();
     $this->fontDirectionHint = $stream->readShort();
     $this->indexToLocFormat = $stream->readShort();
     $this->glyphDataFormat = $stream->readShort();
 }
Example #26
0
 /**
  * Reads the data from the given stream.
  *
  * @param StreamInterface $stream The stream to read from.
  */
 public function read(StreamInterface $stream)
 {
     $this->setVarSelector($stream->readUInt24());
     $this->setDefaultUVSOffset($stream->readULong());
     $this->setNonDefaultUVSOffset($stream->readULong());
 }