Code coverage report for fontkit/src/tables/GSUB.coffee

Statements: 100% (9 / 9)      Branches: 100% (0 / 0)      Functions: 100% (1 / 1)      Lines: 100% (9 / 9)      Ignored: none     

All files » fontkit/src/tables/ » GSUB.coffee
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 651 1   1   1     162   1   1                                                                                           1   1        
r = require 'restructure'
{ScriptList, FeatureList, LookupList, Coverage, ClassDef, Device, Context, ChainingContext} = require './opentype'
 
Sequence = AlternateSet = new r.Array(r.uint16, r.uint16)
  
Ligature = new r.Struct
  glyph:      r.uint16
  compCount:  r.uint16
  components: new r.Array(r.uint16, -> @compCount - 1)
  
LigatureSet = new r.Array(new r.Pointer(r.uint16, Ligature), r.uint16)
 
GSUBLookup = new r.VersionedStruct 'lookupType',
  1: new r.VersionedStruct r.uint16, # Single Substitution
    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')
    
  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
    lookaheadCoverage:      new r.Array(new r.Pointer(r.uint16, Coverage), 'lookaheadGlyphCount')
    glyphCount:             r.uint16
    substitutes:            new r.Array(r.uint16, 'glyphCount')
    
# Fix circular reference
GSUBLookup.versions[7].extension.type = GSUBLookup
  
module.exports = new r.Struct
  version:        r.int32
  scriptList:     new r.Pointer(r.uint16, ScriptList)
  featureList:    new r.Pointer(r.uint16, FeatureList)
  lookupList:     new r.Pointer(r.uint16, new LookupList(GSUBLookup))