forked from signintech/gopdf
-
Notifications
You must be signed in to change notification settings - Fork 0
/
font_obj.go
67 lines (54 loc) · 1.42 KB
/
font_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
59
60
61
62
63
64
65
66
67
package gopdf
import (
"bytes"
"strconv"
)
type FontObj struct { //impl IObj
buffer bytes.Buffer
Family string
//Style string
//Size int
IsEmbedFont bool
indexObjWidth int
indexObjFontDescriptor int
indexObjEncoding int
Font IFont
CountOfFont int
}
func (f *FontObj) init(funcGetRoot func() *GoPdf) {
f.IsEmbedFont = false
//me.CountOfFont = -1
}
func (f *FontObj) build() error {
baseFont := f.Family
if f.Font != nil {
baseFont = f.Font.GetName()
}
f.buffer.WriteString("<<\n")
f.buffer.WriteString(" /Type /" + f.getType() + "\n")
f.buffer.WriteString(" /Subtype /TrueType\n")
f.buffer.WriteString(" /BaseFont /" + baseFont + "\n")
if f.IsEmbedFont {
f.buffer.WriteString(" /FirstChar 32 /LastChar 255\n")
f.buffer.WriteString(" /Widths " + strconv.Itoa(f.indexObjWidth) + " 0 R\n")
f.buffer.WriteString(" /FontDescriptor " + strconv.Itoa(f.indexObjFontDescriptor) + " 0 R\n")
f.buffer.WriteString(" /Encoding " + strconv.Itoa(f.indexObjEncoding) + " 0 R\n")
}
f.buffer.WriteString(">>\n")
return nil
}
func (f *FontObj) getType() string {
return "Font"
}
func (f *FontObj) getObjBuff() *bytes.Buffer {
return &(f.buffer)
}
func (f *FontObj) SetIndexObjWidth(index int) {
f.indexObjWidth = index
}
func (f *FontObj) SetIndexObjFontDescriptor(index int) {
f.indexObjFontDescriptor = index
}
func (f *FontObj) SetIndexObjEncoding(index int) {
f.indexObjEncoding = index
}