forked from signintech/gopdf
-
Notifications
You must be signed in to change notification settings - Fork 0
/
fontdescriptor_obj.go
58 lines (45 loc) · 1.1 KB
/
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
55
56
57
58
package gopdf
import (
"fmt"
"io"
)
// FontDescriptorObj is a font descriptor object.
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"
}
// SetFont sets the font in descriptor.
func (f *FontDescriptorObj) SetFont(font IFont) {
f.font = font
}
// GetFont gets font from descriptor.
func (f *FontDescriptorObj) GetFont() IFont {
return f.font
}
// SetFontFileObjRelate ???
func (f *FontDescriptorObj) SetFontFileObjRelate(relate string) {
f.fontFileObjRelate = relate
}