How to use the restructure.LazyArray function in restructure

To help you get started, we’ve selected a few restructure examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github foliojs / fontkit / src / tables / GPOS.js View on Github external
},
    2: {
      coverage:       new r.Pointer(r.uint16, Coverage),
      valueFormat:    ValueFormat,
      valueCount:     r.uint16,
      values:         new r.LazyArray(new ValueRecord(), 'valueCount')
    }
  }),

  2: new r.VersionedStruct(r.uint16, { // Pair Adjustment Positioning
    1: { // Adjustments for glyph pairs
      coverage:       new r.Pointer(r.uint16, Coverage),
      valueFormat1:   ValueFormat,
      valueFormat2:   ValueFormat,
      pairSetCount:   r.uint16,
      pairSets:       new r.LazyArray(new r.Pointer(r.uint16, PairSet), 'pairSetCount')
    },

    2: { // Class pair adjustment
      coverage:       new r.Pointer(r.uint16, Coverage),
      valueFormat1:   ValueFormat,
      valueFormat2:   ValueFormat,
      classDef1:      new r.Pointer(r.uint16, ClassDef),
      classDef2:      new r.Pointer(r.uint16, ClassDef),
      class1Count:    r.uint16,
      class2Count:    r.uint16,
      classRecords:   new r.LazyArray(new r.LazyArray(Class2Record, 'class2Count'), 'class1Count')
    }
  }),

  3: { // Cursive Attachment Positioning
    format:             r.uint16,
github foliojs / fontkit / src / tables / cmap.js View on Github external
10: { // Trimmed Array
    reserved:       new r.Reserved(r.uint16),
    length:         r.uint32,
    language:       r.uint32,
    firstCode:      r.uint32,
    entryCount:     r.uint32,
    glyphIndices:   new r.LazyArray(r.uint16, 'numChars')
  },

  12: { // Segmented coverage
    reserved: new r.Reserved(r.uint16),
    length:   r.uint32,
    language: r.uint32,
    nGroups:  r.uint32,
    groups:   new r.LazyArray(CmapGroup, 'nGroups')
  },

  13: { // Many-to-one range mappings (same as 12 except for group.startGlyphID)
    reserved: new r.Reserved(r.uint16),
    length:   r.uint32,
    language: r.uint32,
    nGroups:  r.uint32,
    groups:   new r.LazyArray(CmapGroup, 'nGroups')
  },

  14: { // Unicode Variation Sequences
    length:       r.uint32,
    numRecords:   r.uint32,
    varSelectors: new r.LazyArray(VarSelectorRecord, 'numRecords')
  }
});
github foliojs / fontkit / src / tables / cmap.js View on Github external
language:         r.uint16,
    subHeaderKeys:    new r.Array(r.uint16, 256),
    subHeaderCount:   t => Math.max.apply(Math, t.subHeaderKeys),
    subHeaders:       new r.LazyArray(SubHeader, 'subHeaderCount'),
    glyphIndexArray:  new r.LazyArray(r.uint16, 'subHeaderCount')
  },

  4: { // Segment mapping to delta values
    length:           r.uint16,              // Total table length in bytes
    language:         r.uint16,              // Language code
    segCountX2:       r.uint16,
    segCount:         t => t.segCountX2 >> 1,
    searchRange:      r.uint16,
    entrySelector:    r.uint16,
    rangeShift:       r.uint16,
    endCode:          new r.LazyArray(r.uint16, 'segCount'),
    reservedPad:      new r.Reserved(r.uint16),       // This value should be zero
    startCode:        new r.LazyArray(r.uint16, 'segCount'),
    idDelta:          new r.LazyArray(r.int16, 'segCount'),
    idRangeOffset:    new r.LazyArray(r.uint16, 'segCount'),
    glyphIndexArray:  new r.LazyArray(r.uint16, t => (t.length - t._currentOffset) / 2)
  },

  6: { // Trimmed table
    length:         r.uint16,
    language:       r.uint16,
    firstCode:      r.uint16,
    entryCount:     r.uint16,
    glyphIndices:   new r.LazyArray(r.uint16, 'entryCount')
  },

  8: { // mixed 16-bit and 32-bit coverage
github foliojs / fontkit / src / tables / GPOS.js View on Github external
coverage:       new r.Pointer(r.uint16, Coverage),
      valueFormat1:   ValueFormat,
      valueFormat2:   ValueFormat,
      pairSetCount:   r.uint16,
      pairSets:       new r.LazyArray(new r.Pointer(r.uint16, PairSet), 'pairSetCount')
    },

    2: { // Class pair adjustment
      coverage:       new r.Pointer(r.uint16, Coverage),
      valueFormat1:   ValueFormat,
      valueFormat2:   ValueFormat,
      classDef1:      new r.Pointer(r.uint16, ClassDef),
      classDef2:      new r.Pointer(r.uint16, ClassDef),
      class1Count:    r.uint16,
      class2Count:    r.uint16,
      classRecords:   new r.LazyArray(new r.LazyArray(Class2Record, 'class2Count'), 'class1Count')
    }
  }),

  3: { // Cursive Attachment Positioning
    format:             r.uint16,
    coverage:           new r.Pointer(r.uint16, Coverage),
    entryExitCount:     r.uint16,
    entryExitRecords:   new r.Array(EntryExitRecord, 'entryExitCount')
  },

  4: { // MarkToBase Attachment Positioning
    format:             r.uint16,
    markCoverage:       new r.Pointer(r.uint16, Coverage),
    baseCoverage:       new r.Pointer(r.uint16, Coverage),
    classCount:         r.uint16,
    markArray:          new r.Pointer(r.uint16, MarkArray),
github foliojs / fontkit / src / tables / GSUB.js View on Github external
1: {
      coverage:       new r.Pointer(r.uint16, Coverage),
      deltaGlyphID:   r.int16
    },
    2: {
      coverage:       new r.Pointer(r.uint16, Coverage),
      glyphCount:     r.uint16,
      substitute:     new r.LazyArray(r.uint16, 'glyphCount')
    }
  }),

  2: { // Multiple Substitution
    substFormat:    r.uint16,
    coverage:       new r.Pointer(r.uint16, Coverage),
    count:          r.uint16,
    sequences:      new r.LazyArray(new r.Pointer(r.uint16, Sequence), 'count')
  },

  3: { // Alternate Substitution
    substFormat:    r.uint16,
    coverage:       new r.Pointer(r.uint16, Coverage),
    count:          r.uint16,
    alternateSet:   new r.LazyArray(new r.Pointer(r.uint16, AlternateSet), 'count')
  },

  4: { // Ligature Substitution
    substFormat:    r.uint16,
    coverage:       new r.Pointer(r.uint16, Coverage),
    count:          r.uint16,
    ligatureSets:   new r.LazyArray(new r.Pointer(r.uint16, LigatureSet), 'count')
  },
github foliojs / fontkit / src / tables / GSUB.js View on Github external
count:          r.uint16,
    sequences:      new r.LazyArray(new r.Pointer(r.uint16, Sequence), 'count')
  },

  3: { // Alternate Substitution
    substFormat:    r.uint16,
    coverage:       new r.Pointer(r.uint16, Coverage),
    count:          r.uint16,
    alternateSet:   new r.LazyArray(new r.Pointer(r.uint16, AlternateSet), 'count')
  },

  4: { // Ligature Substitution
    substFormat:    r.uint16,
    coverage:       new r.Pointer(r.uint16, Coverage),
    count:          r.uint16,
    ligatureSets:   new r.LazyArray(new r.Pointer(r.uint16, LigatureSet), 'count')
  },

  5: Context,         // Contextual Substitution
  6: ChainingContext, // Chaining Contextual Substitution

  7: { // Extension Substitution
    substFormat:   r.uint16,
    lookupType:    r.uint16,   // cannot also be 7
    extension:     new r.Pointer(r.uint32, GSUBLookup)
  },

  8: { // Reverse Chaining Contextual Single Substitution
    substFormat:            r.uint16,
    coverage:               new r.Pointer(r.uint16, Coverage),
    backtrackCoverage:      new r.Array(new r.Pointer(r.uint16, Coverage), 'backtrackGlyphCount'),
    lookaheadGlyphCount:    r.uint16,
github foliojs / fontkit / src / tables / cmap.js View on Github external
nGroups:  r.uint32,
    groups:   new r.LazyArray(CmapGroup, 'nGroups')
  },

  13: { // Many-to-one range mappings (same as 12 except for group.startGlyphID)
    reserved: new r.Reserved(r.uint16),
    length:   r.uint32,
    language: r.uint32,
    nGroups:  r.uint32,
    groups:   new r.LazyArray(CmapGroup, 'nGroups')
  },

  14: { // Unicode Variation Sequences
    length:       r.uint32,
    numRecords:   r.uint32,
    varSelectors: new r.LazyArray(VarSelectorRecord, 'numRecords')
  }
});

let CmapEntry = new r.Struct({
  platformID:  r.uint16,  // Platform identifier
  encodingID:  r.uint16,  // Platform-specific encoding identifier
  table:       new r.Pointer(r.uint32, CmapSubtable, {type: 'parent', lazy: true})
});

// character to glyph mapping
export default new r.Struct({
  version:      r.uint16,
  numSubtables: r.uint16,
  tables:       new r.Array(CmapEntry, 'numSubtables')
});
github foliojs / fontkit / src / tables / cmap.js View on Github external
subHeaders:       new r.LazyArray(SubHeader, 'subHeaderCount'),
    glyphIndexArray:  new r.LazyArray(r.uint16, 'subHeaderCount')
  },

  4: { // Segment mapping to delta values
    length:           r.uint16,              // Total table length in bytes
    language:         r.uint16,              // Language code
    segCountX2:       r.uint16,
    segCount:         t => t.segCountX2 >> 1,
    searchRange:      r.uint16,
    entrySelector:    r.uint16,
    rangeShift:       r.uint16,
    endCode:          new r.LazyArray(r.uint16, 'segCount'),
    reservedPad:      new r.Reserved(r.uint16),       // This value should be zero
    startCode:        new r.LazyArray(r.uint16, 'segCount'),
    idDelta:          new r.LazyArray(r.int16, 'segCount'),
    idRangeOffset:    new r.LazyArray(r.uint16, 'segCount'),
    glyphIndexArray:  new r.LazyArray(r.uint16, t => (t.length - t._currentOffset) / 2)
  },

  6: { // Trimmed table
    length:         r.uint16,
    language:       r.uint16,
    firstCode:      r.uint16,
    entryCount:     r.uint16,
    glyphIndices:   new r.LazyArray(r.uint16, 'entryCount')
  },

  8: { // mixed 16-bit and 32-bit coverage
    reserved: new r.Reserved(r.uint16),
    length:   r.uint32,
    language: r.uint16,
github foliojs / fontkit / src / tables / cmap.js View on Github external
},

  4: { // Segment mapping to delta values
    length:           r.uint16,              // Total table length in bytes
    language:         r.uint16,              // Language code
    segCountX2:       r.uint16,
    segCount:         t => t.segCountX2 >> 1,
    searchRange:      r.uint16,
    entrySelector:    r.uint16,
    rangeShift:       r.uint16,
    endCode:          new r.LazyArray(r.uint16, 'segCount'),
    reservedPad:      new r.Reserved(r.uint16),       // This value should be zero
    startCode:        new r.LazyArray(r.uint16, 'segCount'),
    idDelta:          new r.LazyArray(r.int16, 'segCount'),
    idRangeOffset:    new r.LazyArray(r.uint16, 'segCount'),
    glyphIndexArray:  new r.LazyArray(r.uint16, t => (t.length - t._currentOffset) / 2)
  },

  6: { // Trimmed table
    length:         r.uint16,
    language:       r.uint16,
    firstCode:      r.uint16,
    entryCount:     r.uint16,
    glyphIndices:   new r.LazyArray(r.uint16, 'entryCount')
  },

  8: { // mixed 16-bit and 32-bit coverage
    reserved: new r.Reserved(r.uint16),
    length:   r.uint32,
    language: r.uint16,
    is32:     new r.LazyArray(r.uint8, 8192),
    nGroups:  r.uint32,