forked from signintech/gopdf
-
Notifications
You must be signed in to change notification settings - Fork 0
/
embedfont_obj.go
45 lines (37 loc) · 896 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 (me *EmbedFontObj) Init(funcGetRoot func()(*GoPdf)) {
}
func (me *EmbedFontObj) Build() {
b, err := ioutil.ReadFile(me.zfontpath)
if err != nil {
return
}
me.buffer.WriteString("<</Length "+ strconv.Itoa(len(b)) +"\n")
me.buffer.WriteString("/Filter /FlateDecode\n")
me.buffer.WriteString("/Length1 "+strconv.Itoa(me.font.GetOriginalsize())+"\n")
me.buffer.WriteString(">>\n")
me.buffer.WriteString("stream\n")
me.buffer.Write(b)
me.buffer.WriteString("\nendstream\n")
}
func (me *EmbedFontObj) GetType() string {
return "EmbedFont"
}
func (me *EmbedFontObj) GetObjBuff() *bytes.Buffer {
return &(me.buffer)
}
func (me *EmbedFontObj) SetFont(font IFont,zfontpath string){
me.font = font
me.zfontpath = zfontpath
}