How to use the restructure.uint8 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 / kern.js View on Github external
entrySelector:  r.uint16,
    rangeShift:     r.uint16,
    pairs:          new r.Array(KernPair, 'nPairs')
  },

  2: {
    rowWidth:   r.uint16,
    leftTable:  new r.Pointer(r.uint16, ClassTable, {type: 'parent'}),
    rightTable: new r.Pointer(r.uint16, ClassTable, {type: 'parent'}),
    array:      new r.Pointer(r.uint16, Kern2Array, {type: 'parent'})
  },

  3: {
    glyphCount:       r.uint16,
    kernValueCount:   r.uint8,
    leftClassCount:   r.uint8,
    rightClassCount:  r.uint8,
    flags:            r.uint8,
    kernValue:        new r.Array(r.int16, 'kernValueCount'),
    leftClass:        new r.Array(r.uint8, 'glyphCount'),
    rightClass:       new r.Array(r.uint8, 'glyphCount'),
    kernIndex:        new r.Array(r.uint8, t => t.leftClassCount * t.rightClassCount)
  }
});

let KernTable = new r.VersionedStruct('version', {
  0: { // Microsoft uses this format
    subVersion: r.uint16,  // Microsoft has an extra sub-table version number
    length:     r.uint16,  // Length of the subtable, in bytes
    format:     r.uint8,   // Format of subtable
    coverage:   new r.Bitfield(r.uint8, [
      'horizontal',    // 1 if table has horizontal data, 0 if vertical
github foliojs / fontkit / src / tables / EBLC.js View on Github external
subtable: new r.Pointer(r.uint32, IndexSubtable)
});

let BitmapSizeTable = new r.Struct({
  indexSubTableArray: new r.Pointer(r.uint32, new r.Array(IndexSubtableArray, 1), { type: 'parent' }),
  indexTablesSize: r.uint32,
  numberOfIndexSubTables: r.uint32,
  colorRef: r.uint32,
  hori: SBitLineMetrics,
  vert: SBitLineMetrics,
  startGlyphIndex: r.uint16,
  endGlyphIndex: r.uint16,
  ppemX: r.uint8,
  ppemY: r.uint8,
  bitDepth: r.uint8,
  flags: new r.Bitfield(r.uint8, ['horizontal', 'vertical'])
});

export default new r.Struct({
  version:  r.uint32, // 0x00020000
  numSizes: r.uint32,
  sizes:    new r.Array(BitmapSizeTable, 'numSizes')
});
github foliojs / fontkit / src / tables / OS2.js View on Github external
fsType:                 new r.Bitfield(r.uint16, [ // Indicates font embedding licensing rights
      null, 'noEmbedding', 'viewOnly', 'editable', null,
      null, null, null, 'noSubsetting', 'bitmapOnly'
    ]),
    ySubscriptXSize:        r.int16,   // recommended horizontal size in pixels for subscripts
    ySubscriptYSize:        r.int16,   // recommended vertical size in pixels for subscripts
    ySubscriptXOffset:      r.int16,   // recommended horizontal offset for subscripts
    ySubscriptYOffset:      r.int16,   // recommended vertical offset form the baseline for subscripts
    ySuperscriptXSize:      r.int16,   // recommended horizontal size in pixels for superscripts
    ySuperscriptYSize:      r.int16,   // recommended vertical size in pixels for superscripts
    ySuperscriptXOffset:    r.int16,   // recommended horizontal offset for superscripts
    ySuperscriptYOffset:    r.int16,   // recommended vertical offset from the baseline for superscripts
    yStrikeoutSize:         r.int16,   // width of the strikeout stroke
    yStrikeoutPosition:     r.int16,   // position of the strikeout stroke relative to the baseline
    sFamilyClass:           r.int16,   // classification of font-family design
    panose:                 new r.Array(r.uint8, 10),   // describe the visual characteristics of a given typeface
    ulCharRange:            new r.Array(r.uint32, 4),
    vendorID:               new r.String(4),          // four character identifier for the font vendor
    fsSelection:            new r.Bitfield(r.uint16, [  // bit field containing information about the font
      'italic', 'underscore', 'negative', 'outlined', 'strikeout',
      'bold', 'regular', 'useTypoMetrics', 'wws', 'oblique'
    ]),
    usFirstCharIndex:       r.uint16,  // The minimum Unicode index in this font
    usLastCharIndex:        r.uint16   // The maximum Unicode index in this font
  },

  // The Apple version of this table ends here, but the Microsoft one continues on...
  0: {},

  1: {
    typoAscender:       r.int16,
    typoDescender:      r.int16,
github foliojs / fontkit / src / tables / LTSH.js View on Github external
import r from 'restructure';

// Linear Threshold table
// Records the ppem for each glyph at which the scaling becomes linear again,
// despite instructions effecting the advance width
export default new r.Struct({
  version:    r.uint16,
  numGlyphs:  r.uint16,
  yPels:      new r.Array(r.uint8, 'numGlyphs')
});
github foliojs / fontkit / src / tables / kern.js View on Github external
2: {
    rowWidth:   r.uint16,
    leftTable:  new r.Pointer(r.uint16, ClassTable, {type: 'parent'}),
    rightTable: new r.Pointer(r.uint16, ClassTable, {type: 'parent'}),
    array:      new r.Pointer(r.uint16, Kern2Array, {type: 'parent'})
  },

  3: {
    glyphCount:       r.uint16,
    kernValueCount:   r.uint8,
    leftClassCount:   r.uint8,
    rightClassCount:  r.uint8,
    flags:            r.uint8,
    kernValue:        new r.Array(r.int16, 'kernValueCount'),
    leftClass:        new r.Array(r.uint8, 'glyphCount'),
    rightClass:       new r.Array(r.uint8, 'glyphCount'),
    kernIndex:        new r.Array(r.uint8, t => t.leftClassCount * t.rightClassCount)
  }
});

let KernTable = new r.VersionedStruct('version', {
  0: { // Microsoft uses this format
    subVersion: r.uint16,  // Microsoft has an extra sub-table version number
    length:     r.uint16,  // Length of the subtable, in bytes
    format:     r.uint8,   // Format of subtable
    coverage:   new r.Bitfield(r.uint8, [
      'horizontal',    // 1 if table has horizontal data, 0 if vertical
      'minimum',       // If set to 1, the table has minimum values. If set to 0, the table has kerning values.
      'crossStream',   // If set to 1, kerning is perpendicular to the flow of the text
      'override'      // If set to 1 the value in this table replaces the accumulated value
    ]),
    subtable:   KernSubtable,
github wowserhq / blizzardry / lib / dbc / entities / power-display.js View on Github external
'use strict';

var r = require('restructure');
var Entity = require('../entity');
var StringRef = require('../string-ref');

module.exports = Entity({
  id: r.uint32le,
  type: r.uint32le,
  name: StringRef,
  rgb: new r.Array(r.uint8, 3)
});
github wowserhq / blizzardry / lib / dbc / entities / char-start-outfit.js View on Github external
'use strict';

var r = require('restructure');
var Entity = require('../entity');

module.exports = Entity({
  id: r.uint32le,
  raceID: r.uint8,
  classID: r.uint8,
  gender: r.uint8,
  outfitID: r.uint8,

  itemIDs: new r.Array(r.int32le, 24),
  displayInfoIDs: new r.Array(r.int32le, 24),
  inventoryTypes: new r.Array(r.int32le, 24)
});
github wowserhq / blizzardry / src / lib / adt / index.js View on Github external
return this.parent.parent.MMDX.filenames[this.index];
    },
  }), 'size', 'bytes'),
});

const MCVT = Chunk({
  heights: new r.Array(r.floatle, 145),
});

const MCNR = Chunk({
  normals: new r.Array(new r.Struct({
    x: r.int8,
    z: r.int8,
    y: r.int8,
  }), 145),
  skip: new r.Reserved(r.uint8, 13),
});

const MCLY = Chunk({
  layers: new r.Array(new r.Struct({
    textureID: r.uint32le,
    flags: r.uint32le,
    offsetMCAL: r.uint32le,
    effectID: r.int16le,
    skip: r.int16le,

    compressed: function () {
      return this.flags & 0x200;
    },
  }), 'size', 'bytes'),
});
github cytle / wechat_web_devtools / package.nw / node_modules / fontkit / src / tables / CPAL.js View on Github external
import r from 'restructure';

let ColorRecord = new r.Struct({
  blue: r.uint8,
  green: r.uint8,
  red: r.uint8,
  alpha: r.uint8
});

export default new r.VersionedStruct(r.uint16, {
  header: {
    numPaletteEntries: r.uint16,
    numPalettes: r.uint16,
    numColorRecords: r.uint16,
    colorRecords: new r.Pointer(r.uint32, new r.Array(ColorRecord, 'numColorRecords')),
    colorRecordIndices: new r.Array(r.uint16, 'numPalettes'),
  },
  0: {},
  1: {
    offsetPaletteTypeArray: new r.Pointer(r.uint32, new r.Array(r.uint32, 'numPalettes')),
github wowserhq / blizzardry / src / lib / wmo / group.js View on Github external
colors: new r.Array(new r.Struct({
    b: r.uint8,
    g: r.uint8,
    r: r.uint8,
    a: r.uint8,
  }), 'size', 'bytes'),
});

const MOBA = Chunk({
  batches: new r.Array(new r.Struct({
    skips: new r.Reserved(r.int16le, 2 * 3),
    firstIndex: r.uint32le,
    indexCount: r.uint16le,
    firstVertex: r.uint16le,
    lastVertex: r.uint16le,
    skip: new r.Reserved(r.uint8),
    materialID: r.uint8,
  }), 'size', 'bytes'),
});

const MODR = Chunk({
  doodadIndices: new r.Array(r.int16le, 'size', 'bytes'),
});

export default Chunked({
  MOGP: MOGP,
  MOPY: MOPY,
  MOVI: MOVI,
  MOVT: MOVT,
  MONR: MONR,
  MOTV: MOTV,
  MOBA: MOBA,