1 Star 0 Fork 0

广州捷仓科技有限公司/gopdf

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
cid_font_obj.go 1.54 KB
一键复制 编辑 原始数据 按行查看 历史
mkusaka 提交于 2023-01-08 18:57 . gofmt on go 1.19
package gopdf
import (
"fmt"
"io"
)
// CIDFontObj is a CID-keyed font.
// cf. https://www.adobe.com/content/dam/acom/en/devnet/font/pdfs/5014.CIDFont_Spec.pdf
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
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/jiecang-tech/gopdf.git
git@gitee.com:jiecang-tech/gopdf.git
jiecang-tech
gopdf
gopdf
master

搜索帮助