makeHeadTable function

dynamic makeHeadTable(
  1. dynamic options
)

Implementation

makeHeadTable(options) {
    // Apple Mac timestamp epoch is 01/01/1904 not 01/01/1970
    var timestamp = Math.round( DateTime.now().millisecondsSinceEpoch / 1000) + 2082844800;
    var createdTimestamp = timestamp;

    if (options.createdTimestamp) {
        createdTimestamp = options.createdTimestamp + 2082844800;
    }

    return new Table('head', [
        {"name": 'version', "type": 'FIXED', "value": 0x00010000},
        {"name": 'fontRevision', "type": 'FIXED', "value": 0x00010000},
        {"name": 'checkSumAdjustment', "type": 'ULONG', "value": 0},
        {"name": 'magicNumber', "type": 'ULONG', "value": 0x5F0F3CF5},
        {"name": 'flags', "type": 'USHORT', "value": 0},
        {"name": 'unitsPerEm', "type": 'USHORT', "value": 1000},
        {"name": 'created', "type": 'LONGDATETIME', "value": createdTimestamp},
        {"name": 'modified', "type": 'LONGDATETIME', "value": timestamp},
        {"name": 'xMin', "type": 'SHORT', "value": 0},
        {"name": 'yMin', "type": 'SHORT', "value": 0},
        {"name": 'xMax', "type": 'SHORT', "value": 0},
        {"name": 'yMax', "type": 'SHORT', "value": 0},
        {"name": 'macStyle', "type": 'USHORT', "value": 0},
        {"name": 'lowestRecPPEM', "type": 'USHORT', "value": 0},
        {"name": 'fontDirectionHint', "type": 'SHORT', "value": 2},
        {"name": 'indexToLocFormat', "type": 'SHORT', "value": 0},
        {"name": 'glyphDataFormat', "type": 'SHORT', "value": 0}
    ], options);
}