// Copyright (c) Six Labors. // Licensed under the Six Labors Split License. using System.IO; namespace SixLabors.Fonts.Tables.AdvancedTypographic { /// /// A SequenceRule table describes a context rule using glyph IDs in Sequence Context Format 1. /// /// internal sealed class SequenceRuleTable { /// /// Initializes a new instance of the class. /// /// The array of input glyph IDs, starting with the second glyph. /// The array of sequence lookup records. private SequenceRuleTable(ushort[] inputSequence, SequenceLookupRecord[] seqLookupRecords) { this.InputSequence = inputSequence; this.SequenceLookupRecords = seqLookupRecords; } /// /// Gets the array of input glyph IDs, starting with the second glyph. /// public ushort[] InputSequence { get; } /// /// Gets the array of sequence lookup records specifying actions to be applied. /// public SequenceLookupRecord[] SequenceLookupRecords { get; } /// /// Loads the from the binary reader at the specified offset. /// /// The big endian binary reader. /// Offset from the beginning of the SequenceRule table. /// The . public static SequenceRuleTable Load(BigEndianBinaryReader reader, long offset) { // +----------------------+----------------------------------+---------------------------------------------------------+ // | Type | Name | Description | // +======================+==================================+=========================================================+ // | uint16 | glyphCount | Number of glyphs in the input glyph sequence | // +----------------------+----------------------------------+---------------------------------------------------------+ // | uint16 | seqLookupCount | Number of SequenceLookupRecords | // +----------------------+----------------------------------+---------------------------------------------------------+ // | uint16 | inputSequence[glyphCount - 1] | Array of input glyph IDs—starting with the second glyph | // +----------------------+----------------------------------+---------------------------------------------------------+ // | SequenceLookupRecord | seqLookupRecords[seqLookupCount] | Array of Sequence lookup records | // +----------------------+----------------------------------+---------------------------------------------------------+ reader.Seek(offset, SeekOrigin.Begin); ushort glyphCount = reader.ReadUInt16(); ushort seqLookupCount = reader.ReadUInt16(); ushort[] inputSequence = reader.ReadUInt16Array(glyphCount - 1); SequenceLookupRecord[] seqLookupRecords = SequenceLookupRecord.LoadArray(reader, seqLookupCount); return new SequenceRuleTable(inputSequence, seqLookupRecords); } } }