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

100% Statements 5/5
100% Branches 0/0
100% Functions 0/0
100% Lines 5/5
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                                                
r = require 'restructure'
 
# VDMX tables contain ascender/descender overrides for certain (usually small) 
# sizes. This is needed in order to match font metrics on Windows.
 
Ratio = new r.Struct
  bCharSet:       r.uint8                             # Character set
  xRatio:         r.uint8                             # Value to use for x-Ratio
  yStartRatio:    r.uint8                             # Starting y-Ratio value
  yEndRatio:      r.uint8                             # Ending y-Ratio value
                                                    
vTable = new r.Struct                                
  yPelHeight:     r.uint16                            # yPelHeight to which values apply
  yMax:           r.int16                             # Maximum value (in pels) for this yPelHeight
  yMin:           r.int16                             # Minimum value (in pels) for this yPelHeight
                                                    
VdmxGroup = new r.Struct                              
  recs:           r.uint16                            # Number of height records in this group
  startsz:        r.uint8                             # Starting yPelHeight
  endsz:          r.uint8                             # Ending yPelHeight
  entries:        new r.Array(vTable, 'recs')        # The VDMX records
 
module.exports = new r.Struct
  version:        r.uint16                            # Version number (0 or 1)
  numRecs:        r.uint16                            # Number of VDMX groups present
  numRatios:      r.uint16                            # Number of aspect ratio groupings
  ratioRanges:    new r.Array(Ratio, 'numRatios')    # Ratio ranges
  offsets:        new r.Array(r.uint16, 'numRatios')   # Offset to the VDMX group for this ratio range
  groups:         new r.Array(VdmxGroup, 'numRecs')  # The actual VDMX groupings