all files / fontkit/src/tables/ morx.coffee

100% Statements 12/12
100% Branches 0/0
100% Functions 1/1
100% Lines 12/12
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66                                                                         44×                                    
r = require 'restructure'
{UnboundedArray, LookupTable, StateTable} = require './aat'
 
LigatureData =
  action: r.uint16
  
ContextualData =
  markIndex: r.uint16
  currentIndex: r.uint16
  
InsertionData =
  currentInsertIndex: r.uint16
  markedInsertIndex: r.uint16
  
SubstitutionTable = new r.Struct
  items: new UnboundedArray(new r.Pointer(r.uint32, new LookupTable))
  
SubtableData = new r.VersionedStruct 'type',
  0: # Indic Rearrangement Subtable
    stateTable: new StateTable
 
  1: # Contextual Glyph Substitution Subtable
    stateTable: new StateTable ContextualData
    substitutionTable: new r.Pointer(r.uint32, SubstitutionTable)
 
  2: # Ligature subtable
    stateTable: new StateTable LigatureData
    ligatureActions: new r.Pointer(r.uint32, new UnboundedArray(r.uint32))
    components: new r.Pointer(r.uint32, new UnboundedArray(r.uint16))
    ligatureList: new r.Pointer(r.uint32, new UnboundedArray(r.uint16))
    
  4: # Non-contextual Glyph Substitution Subtable
    lookupTable: new LookupTable
 
  5: # Glyph Insertion Subtable
    stateTable: new StateTable InsertionData
    insertionActions: new r.Pointer(r.uint32, new UnboundedArray(r.uint16))
    
Subtable = new r.Struct
  length: r.uint32
  coverage: r.uint24
  type: r.uint8
  subFeatureFlags: r.uint32
  table: SubtableData
  padding: new r.Reserved r.uint8, -> @length - @_currentOffset
 
FeatureEntry = new r.Struct
  featureType:    r.uint16
  featureSetting: r.uint16
  enableFlags:    r.uint32
  disableFlags:   r.uint32
 
MorxChain = new r.Struct
  defaultFlags:     r.uint32
  chainLength:      r.uint32
  nFeatureEntries:  r.uint32
  nSubtables:       r.uint32
  features:         new r.Array(FeatureEntry, 'nFeatureEntries')
  subtables:        new r.Array(Subtable, 'nSubtables')
 
module.exports = new r.Struct
  version:  r.uint16
  unused:   new r.Reserved(r.uint16)
  nChains:  r.uint32
  chains:   new r.Array(MorxChain, 'nChains')