|
| 1 | +// The `vhea` table contains information for vertical layout. |
| 2 | +// https://learn.microsoft.com/en-us/typography/opentype/spec/vhea |
| 3 | + |
| 4 | +import parse from '../parse.mjs'; |
| 5 | +import table from '../table.mjs'; |
| 6 | + |
| 7 | +// Parse the vertical header `vhea` table |
| 8 | +function parseVheaTable(data, start) { |
| 9 | + const vhea = {}; |
| 10 | + const p = new parse.Parser(data, start); |
| 11 | + vhea.version = p.parseVersion(); |
| 12 | + vhea.ascent = p.parseShort(); // v1.0 |
| 13 | + vhea.vertTypoAscender = vhea.ascent; // v1.1 |
| 14 | + vhea.descent = p.parseShort(); // v1.0 |
| 15 | + vhea.vertTypoDescender = vhea.descent; // v1.1 |
| 16 | + vhea.lineGap = p.parseShort(); // v1.0 |
| 17 | + vhea.vertTypoLineGap = vhea.lineGap; // v1.1 |
| 18 | + vhea.advanceHeightMax = p.parseUShort(); |
| 19 | + vhea.minTopSideBearing = p.parseShort(); |
| 20 | + vhea.minBottomSideBearing = p.parseShort(); |
| 21 | + vhea.yMaxExtent = p.parseShort(); |
| 22 | + vhea.caretSlopeRise = p.parseShort(); |
| 23 | + vhea.caretSlopeRun = p.parseShort(); |
| 24 | + vhea.caretOffset = p.parseShort(); |
| 25 | + p.relativeOffset += 8; |
| 26 | + vhea.metricDataFormat = p.parseShort(); |
| 27 | + vhea.numOfLongVerMetrics = p.parseUShort(); |
| 28 | + return vhea; |
| 29 | +} |
| 30 | + |
| 31 | +function makeVheaTable(options) { |
| 32 | + return new table.Table('vhea', [ |
| 33 | + {name: 'version', type: 'FIXED', value: 0x00010000}, |
| 34 | + {name: 'ascent', type: 'FWORD', value: 0}, |
| 35 | + {name: 'descent', type: 'FWORD', value: 0}, |
| 36 | + {name: 'lineGap', type: 'FWORD', value: 0}, |
| 37 | + {name: 'advanceHeightMax', type: 'UFWORD', value: 0}, |
| 38 | + {name: 'minTopSideBearing', type: 'FWORD', value: 0}, |
| 39 | + {name: 'minBottomSideBearing', type: 'FWORD', value: 0}, |
| 40 | + {name: 'yMaxExtent', type: 'FWORD', value: 0}, |
| 41 | + {name: 'caretSlopeRise', type: 'SHORT', value: 1}, |
| 42 | + {name: 'caretSlopeRun', type: 'SHORT', value: 0}, |
| 43 | + {name: 'caretOffset', type: 'SHORT', value: 0}, |
| 44 | + {name: 'reserved1', type: 'SHORT', value: 0}, |
| 45 | + {name: 'reserved2', type: 'SHORT', value: 0}, |
| 46 | + {name: 'reserved3', type: 'SHORT', value: 0}, |
| 47 | + {name: 'reserved4', type: 'SHORT', value: 0}, |
| 48 | + {name: 'metricDataFormat', type: 'SHORT', value: 0}, |
| 49 | + {name: 'numOfLongVerMetrics', type: 'USHORT', value: 0} |
| 50 | + ], options); |
| 51 | +} |
| 52 | + |
| 53 | +export default { parse: parseVheaTable, make: makeVheaTable }; |
0 commit comments