github.com/signintech/pdft@v0.5.0/minigopdf/fontdescriptor_obj.go (about) 1 package gopdf 2 3 import ( 4 "bytes" 5 ) 6 7 type FontDescriptorObj struct { 8 buffer bytes.Buffer 9 font IFont 10 fontFileObjRelate string 11 } 12 13 func (f *FontDescriptorObj) init(funcGetRoot func() *GoPdf) { 14 15 } 16 17 func (f *FontDescriptorObj) build(objID int) error { 18 19 f.buffer.WriteString("<</Type /FontDescriptor /FontName /" + f.font.GetName() + " ") 20 descs := f.font.GetDesc() 21 i := 0 22 max := len(descs) 23 for i < max { 24 f.buffer.WriteString("/" + descs[i].Key + " " + descs[i].Val + " ") 25 i++ 26 } 27 28 if f.getType() == "Type1" { 29 f.buffer.WriteString("/FontFile ") 30 } else { 31 f.buffer.WriteString("/FontFile2 ") 32 } 33 34 f.buffer.WriteString(f.fontFileObjRelate) 35 f.buffer.WriteString(">>\n") 36 37 return nil 38 } 39 40 func (f *FontDescriptorObj) getType() string { 41 return "FontDescriptor" 42 } 43 44 func (f *FontDescriptorObj) getObjBuff() *bytes.Buffer { 45 return &(f.buffer) 46 } 47 48 func (f *FontDescriptorObj) SetFont(font IFont) { 49 f.font = font 50 } 51 52 func (f *FontDescriptorObj) GetFont() IFont { 53 return f.font 54 } 55 56 func (f *FontDescriptorObj) SetFontFileObjRelate(relate string) { 57 f.fontFileObjRelate = relate 58 }