forked from unidoc/unitype
-
Notifications
You must be signed in to change notification settings - Fork 0
/
table_fpgm.go
42 lines (35 loc) · 838 Bytes
/
table_fpgm.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
import (
"github.com/sirupsen/logrus"
)
// fpgmTable represents font program instructions and is needed by fonts that are instructed.
type fpgmTable struct {
instructions []uint8
}
func (f *font) parseFpgm(r *byteReader) (*fpgmTable, error) {
tr, has, err := f.seekToTable(r, "fpgm")
if err != nil {
return nil, err
}
if !has || tr == nil {
logrus.Debug("fpgm table absent")
return nil, nil
}
t := &fpgmTable{}
numVals := int(tr.length)
err = r.readSlice(&t.instructions, numVals)
if err != nil {
return nil, err
}
return t, nil
}
func (f *font) writeFpgm(w *byteWriter) error {
if f.fpgm == nil {
return nil
}
return w.writeSlice(f.fpgm.instructions)
}