You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
32 lines
1013 B
32 lines
1013 B
2 years ago
|
'use strict';
|
||
|
|
||
|
// See documentation here: http://www.microsoft.com/typography/otspec/hhea.htm
|
||
|
|
||
|
var ByteBuffer = require('microbuffer');
|
||
|
|
||
|
function createHHeadTable(font) {
|
||
|
|
||
|
var buf = new ByteBuffer(36); // fixed table length
|
||
|
|
||
|
buf.writeInt32(0x10000); // version
|
||
|
buf.writeInt16(font.ascent); // ascent
|
||
|
buf.writeInt16(font.descent); // descend
|
||
|
// Non zero lineGap causes offset in IE, https://github.com/fontello/svg2ttf/issues/37
|
||
|
buf.writeInt16(0); // lineGap
|
||
|
buf.writeUint16(font.maxWidth); // advanceWidthMax
|
||
|
buf.writeInt16(font.minLsb); // minLeftSideBearing
|
||
|
buf.writeInt16(font.minRsb); // minRightSideBearing
|
||
|
buf.writeInt16(font.maxExtent); // xMaxExtent
|
||
|
buf.writeInt16(1); // caretSlopeRise
|
||
|
buf.writeInt16(0); // caretSlopeRun
|
||
|
buf.writeUint32(0); // reserved1
|
||
|
buf.writeUint32(0); // reserved2
|
||
|
buf.writeUint16(0); // reserved3
|
||
|
buf.writeInt16(0); // metricDataFormat
|
||
|
buf.writeUint16(font.glyphs.length); // numberOfHMetrics
|
||
|
|
||
|
return buf;
|
||
|
}
|
||
|
|
||
|
module.exports = createHHeadTable;
|