forked from signintech/gopdf
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cid_font_obj.go
51 lines (44 loc) · 1.42 KB
/
cid_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
package gopdf
import (
"fmt"
"io"
)
type CIDFontObj struct {
PtrToSubsetFontObj *SubsetFontObj
indexObjSubfontDescriptor int
}
func (ci *CIDFontObj) init(funcGetRoot func() *GoPdf) {
}
//SetIndexObjSubfontDescriptor set indexObjSubfontDescriptor
func (ci *CIDFontObj) SetIndexObjSubfontDescriptor(index int) {
ci.indexObjSubfontDescriptor = index
}
func (ci *CIDFontObj) getType() string {
return "CIDFont"
}
func (ci *CIDFontObj) write(w io.Writer, objID int) error {
io.WriteString(w, "<<\n")
fmt.Fprintf(w, "/BaseFont /%s\n", CreateEmbeddedFontSubsetName(ci.PtrToSubsetFontObj.GetFamily()))
io.WriteString(w, "/CIDSystemInfo\n")
io.WriteString(w, "<<\n")
io.WriteString(w, " /Ordering (Identity)\n")
io.WriteString(w, " /Registry (Adobe)\n")
io.WriteString(w, " /Supplement 0\n")
io.WriteString(w, ">>\n")
fmt.Fprintf(w, "/FontDescriptor %d 0 R\n", ci.indexObjSubfontDescriptor+1) //TODO fix
io.WriteString(w, "/Subtype /CIDFontType2\n")
io.WriteString(w, "/Type /Font\n")
glyphIndexs := ci.PtrToSubsetFontObj.CharacterToGlyphIndex.AllVals()
io.WriteString(w, "/W [")
for _, v := range glyphIndexs {
width := ci.PtrToSubsetFontObj.GlyphIndexToPdfWidth(v)
fmt.Fprintf(w, "%d[%d]", v, width)
}
io.WriteString(w, "]\n")
io.WriteString(w, ">>\n")
return nil
}
//SetPtrToSubsetFontObj set PtrToSubsetFontObj
func (ci *CIDFontObj) SetPtrToSubsetFontObj(ptr *SubsetFontObj) {
ci.PtrToSubsetFontObj = ptr
}