How to use the restructure.String 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 / OS2.js View on Github external
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,
    typoLineGap:        r.int16,
    winAscent:          r.uint16,
github foliojs / fontkit / src / tables / opentype.js View on Github external
featureIndexes:   new r.Array(r.uint16, 'featureCount')
});

let LangSysRecord = new r.Struct({
  tag:      new r.String(4),
  langSys:  new r.Pointer(r.uint16, LangSysTable, { type: 'parent' })
});

let Script = new r.Struct({
  defaultLangSys: new r.Pointer(r.uint16, LangSysTable),
  count:          r.uint16,
  langSysRecords: new r.Array(LangSysRecord, 'count')
});

let ScriptRecord = new r.Struct({
  tag:    new r.String(4),
  script: new r.Pointer(r.uint16, Script, { type: 'parent' })
});

export let ScriptList = new r.Array(ScriptRecord, r.uint16);

//#######################
// Features and Lookups #
//#######################

export let Feature = new r.Struct({
  featureParams:      r.uint16, // pointer
  lookupCount:        r.uint16,
  lookupListIndexes:  new r.Array(r.uint16, 'lookupCount')
});

let FeatureRecord = new r.Struct({
github foliojs / fontkit / src / tables / post.js View on Github external
italicAngle:        r.fixed32, // Italic angle in counter-clockwise degrees from the vertical.
    underlinePosition:  r.int16,   // Suggested distance of the top of the underline from the baseline
    underlineThickness: r.int16,   // Suggested values for the underline thickness
    isFixedPitch:       r.uint32,  // Whether the font is monospaced
    minMemType42:       r.uint32,  // Minimum memory usage when a TrueType font is downloaded as a Type 42 font
    maxMemType42:       r.uint32,  // Maximum memory usage when a TrueType font is downloaded as a Type 42 font
    minMemType1:        r.uint32,  // Minimum memory usage when a TrueType font is downloaded as a Type 1 font
    maxMemType1:        r.uint32   // Maximum memory usage when a TrueType font is downloaded as a Type 1 font
  },

  1: {}, // version 1 has no additional fields

  2: {
    numberOfGlyphs: r.uint16,
    glyphNameIndex: new r.Array(r.uint16, 'numberOfGlyphs'),
    names:          new r.Array(new r.String(r.uint8))
  },

  2.5: {
    numberOfGlyphs: r.uint16,
    offsets:        new r.Array(r.uint8, 'numberOfGlyphs')
  },

  3: {}, // version 3 has no additional fields

  4: {
    map: new r.Array(r.uint32, t => t.parent.maxp.numGlyphs)
  }
});
github wowserhq / blizzardry / lib / adt / index.js View on Github external
offsetMODF: r.uint32le,
  offsetMFBO: r.uint32le,
  offsetMH2O: r.uint32le,
  offsetMCNKs: r.uint32le,
  offsetMTXF: r.uint32le,
  offsetMTXP: r.uint32le,

  skip: new r.Reserved(r.uint32le, 2)
});

var MTEX = Chunk({
  filenames: new r.Array(new r.String(null), 'size', 'bytes')
});

var MMDX = Chunk({
  filenames: new r.Array(new r.String(null), 'size', 'bytes')
});

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

var 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)
});

var MCLY = Chunk({
github wowserhq / blizzardry / src / lib / dbc / entities / banned-add-ons.js View on Github external
import r from 'restructure';

import Entity from '../entity';

export default Entity({
  id: r.uint32le,
  nameHash: new r.String(16, 'hex'),
  versionHash: new r.String(16, 'hex'),
  lastModified: r.uint32le,
  flags: r.uint32le,
});
github foliojs / fontkit / src / glyph / SBIXGlyph.js View on Github external
import TTFGlyph from './TTFGlyph';
import r from 'restructure';

let SBIXImage = new r.Struct({
  originX: r.uint16,
  originY: r.uint16,
  type: new r.String(4),
  data: new r.Buffer(t => t.parent.buflen - t._currentOffset)
});

/**
 * Represents a color (e.g. emoji) glyph in Apple's SBIX format.
 */
export default class SBIXGlyph extends TTFGlyph {
  /**
   * Returns an object representing a glyph image at the given point size.
   * The object has a data property with a Buffer containing the actual image data,
   * along with the image type, and origin.
   *
   * @param {number} size
   * @return {object}
   */
  getImageForSize(size) {
github wowserhq / blizzardry / src / lib / m2 / index.js View on Github external
this.rotation.animated ||
           this.scaling.animated ||
           this.billboarded;
  },
});

const Material = new r.Struct({
  renderFlags: r.uint16le,
  blendingMode: r.uint16le,
});

const Texture = new r.Struct({
  type: r.uint32le,
  flags: r.uint32le,
  length: r.uint32le,
  filename: new r.Pointer(r.uint32le, new r.String(null), 'global'),
});

const Vertex = new r.Struct({
  position: float32array3,
  boneWeights: new r.Array(r.uint8, 4),
  boneIndices: new r.Array(r.uint8, 4),
  normal: float32array3,
  textureCoords: new r.Array(float32array2, 2),
});

const Color = new r.Struct({
  color: new AnimationBlock(float32array3),
  alpha: new AnimationBlock(color16),
});

const UVAnimation = new r.Struct({
github wowserhq / blizzardry / lib / dbc / entities / banned-add-ons.js View on Github external
'use strict';

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

module.exports = Entity({
  id: r.uint32le,
  nameHash: new r.String(16, 'hex'),
  versionHash: new r.String(16, 'hex'),
  lastModified: r.uint32le,
  flags: r.uint32le
});
github wowserhq / blizzardry / src / lib / dbc / index.js View on Github external
import r from 'restructure';
import xtend from 'xtend';

const DBC = new r.Struct({
  signature: new r.String(4),

  recordCount: r.uint32le,
  fieldCount: r.uint32le,
  recordSize: r.uint32le,
  stringBlockSize: r.uint32le,
  stringBlockOffset: function () {
    return 4 * 5 + this.recordCount * this.recordSize;
  },

  records: new r.Array(new r.Buffer(function () {
    return this.recordSize;
  }), function () {
    return this.recordCount;
  }),

  stringBlock: new r.Buffer(function () {
github foliojs / fontkit / src / tables / name.js View on Github external
let NameRecord = new r.Struct({
  platformID: r.uint16,
  encodingID: r.uint16,
  languageID: r.uint16,
  nameID:     r.uint16,
  length:     r.uint16,
  string:     new r.Pointer(r.uint16,
    new r.String('length', t => getEncoding(t.platformID, t.encodingID, t.languageID)),
    { type: 'parent', relativeTo: 'parent.stringOffset', allowNull: false }
  )
});

let LangTagRecord = new r.Struct({
  length:  r.uint16,
  tag:     new r.Pointer(r.uint16, new r.String('length', 'utf16be'), {type: 'parent', relativeTo: 'stringOffset'})
});

var NameTable = new r.VersionedStruct(r.uint16, {
  0: {
    count:          r.uint16,
    stringOffset:   r.uint16,
    records:        new r.Array(NameRecord, 'count')
  },
  1: {
    count:          r.uint16,
    stringOffset:   r.uint16,
    records:        new r.Array(NameRecord, 'count'),
    langTagCount:   r.uint16,
    langTags:       new r.Array(LangTagRecord, 'langTagCount')
  }
});