forked from signintech/gopdf
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathembedfont_obj.go
45 lines (38 loc) · 918 Bytes
/
embedfont_obj.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
43
44
45
package gopdf
import (
"bytes"
"io/ioutil"
"strconv"
)
type EmbedFontObj struct {
buffer bytes.Buffer
Data string
zfontpath string
font IFont
}
func (e *EmbedFontObj) init(funcGetRoot func() *GoPdf) {
}
func (e *EmbedFontObj) build() error {
b, err := ioutil.ReadFile(e.zfontpath)
if err != nil {
return err
}
e.buffer.WriteString("<</Length " + strconv.Itoa(len(b)) + "\n")
e.buffer.WriteString("/Filter /FlateDecode\n")
e.buffer.WriteString("/Length1 " + strconv.Itoa(e.font.GetOriginalsize()) + "\n")
e.buffer.WriteString(">>\n")
e.buffer.WriteString("stream\n")
e.buffer.Write(b)
e.buffer.WriteString("\nendstream\n")
return nil
}
func (e *EmbedFontObj) getType() string {
return "EmbedFont"
}
func (e *EmbedFontObj) getObjBuff() *bytes.Buffer {
return &(e.buffer)
}
func (e *EmbedFontObj) SetFont(font IFont, zfontpath string) {
e.font = font
e.zfontpath = zfontpath
}