forked from unidoc/unitype
-
Notifications
You must be signed in to change notification settings - Fork 0
/
table_offset.go
42 lines (34 loc) · 909 Bytes
/
table_offset.go
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
/*
* This file is subject to the terms and conditions defined in
* file 'LICENSE.md', which is part of this source code package.
*/
package unitype
type offsetTable struct {
sfntVersion uint32
numTables uint16
searchRange uint16
entrySelector uint16
rangeShift uint16
}
// Size returns size of `t` in bytes.
func (t *offsetTable) Size() int64 {
return 4 + 4*2 // 4+8=12
}
func (f *font) parseOffsetTable(r *byteReader) (*offsetTable, error) {
ot := &offsetTable{}
err := r.read(&ot.sfntVersion, &ot.numTables, &ot.searchRange)
if err != nil {
return nil, err
}
err = r.read(&ot.entrySelector, &ot.rangeShift)
if err != nil {
return nil, err
}
return ot, nil
}
func (f *font) writeOffsetTable(w *byteWriter) error {
if f.ot == nil {
return errRequiredField
}
return w.write(f.ot.sfntVersion, f.ot.numTables, f.ot.searchRange, f.ot.entrySelector, f.ot.rangeShift)
}