-
Notifications
You must be signed in to change notification settings - Fork 1.2k
/
Copy pathhead.coffee
52 lines (44 loc) · 1.35 KB
/
head.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
Table = require '../table'
Data = require '../../data'
class HeadTable extends Table
tag: 'head'
parse: (data) ->
data.pos = @offset
@version = data.readInt()
@revision = data.readInt()
@checkSumAdjustment = data.readInt()
@magicNumber = data.readInt()
@flags = data.readShort()
@unitsPerEm = data.readShort()
@created = data.readLongLong()
@modified = data.readLongLong()
@xMin = data.readShort()
@yMin = data.readShort()
@xMax = data.readShort()
@yMax = data.readShort()
@macStyle = data.readShort()
@lowestRecPPEM = data.readShort()
@fontDirectionHint = data.readShort()
@indexToLocFormat = data.readShort()
@glyphDataFormat = data.readShort()
encode: (loca) ->
table = new Data
table.writeInt @version
table.writeInt @revision
table.writeInt @checkSumAdjustment
table.writeInt @magicNumber
table.writeShort @flags
table.writeShort @unitsPerEm
table.writeLongLong @created
table.writeLongLong @modified
table.writeShort @xMin
table.writeShort @yMin
table.writeShort @xMax
table.writeShort @yMax
table.writeShort @macStyle
table.writeShort @lowestRecPPEM
table.writeShort @fontDirectionHint
table.writeShort loca.type
table.writeShort @glyphDataFormat
return table.data
module.exports = HeadTable