forked from signintech/gopdf
/
fontdescriptor_obj.go
54 lines (41 loc) · 970 Bytes
/
fontdescriptor_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
46
47
48
49
50
51
52
53
54
package gopdf
import (
"fmt"
"io"
)
type FontDescriptorObj struct {
font IFont
fontFileObjRelate string
}
func (f *FontDescriptorObj) init(funcGetRoot func() *GoPdf) {
}
func (f *FontDescriptorObj) write(w io.Writer, objID int) error {
fmt.Fprintf(w, "<</Type /FontDescriptor /FontName /%s ", f.font.GetName())
descs := f.font.GetDesc()
i := 0
max := len(descs)
for i < max {
fmt.Fprintf(w, "/%s %s ", descs[i].Key, descs[i].Val)
i++
}
if f.getType() == "Type1" {
io.WriteString(w, "/FontFile ")
} else {
io.WriteString(w, "/FontFile2 ")
}
io.WriteString(w, f.fontFileObjRelate)
io.WriteString(w, ">>\n")
return nil
}
func (f *FontDescriptorObj) getType() string {
return "FontDescriptor"
}
func (f *FontDescriptorObj) SetFont(font IFont) {
f.font = font
}
func (f *FontDescriptorObj) GetFont() IFont {
return f.font
}
func (f *FontDescriptorObj) SetFontFileObjRelate(relate string) {
f.fontFileObjRelate = relate
}