mirror of
https://github.com/xiaoqidun/ofdgo.git
synced 2026-10-29 17:27:08 +08:00
This commit is contained in:
1 parent
6c9b3f6019
commit
777d0c7c89
8 files changed
+253
-178
No files matched your search
@@ -32,6 +32,7 @@ type Reader struct {
|
||||
RootDir string
|
||||
ResMap map[string]string
|
||||
fontCache map[string]*Font
|
||||
colorSpaceCache map[string]*ColorSpace
|
||||
drawParamCache map[string]*DrawParam
|
||||
compositeGraphicUnitCache map[string]*CompositeGraphicUnit
|
||||
doc *Document
|
||||
@@ -74,6 +75,7 @@ func (r *Reader) initRoot() error {
|
||||
r.OFD = &ofd
|
||||
r.ResMap = make(map[string]string)
|
||||
r.fontCache = make(map[string]*Font)
|
||||
r.colorSpaceCache = make(map[string]*ColorSpace)
|
||||
r.drawParamCache = make(map[string]*DrawParam)
|
||||
r.compositeGraphicUnitCache = make(map[string]*CompositeGraphicUnit)
|
||||
return nil
|
||||
@@ -186,6 +188,10 @@ func (r *Reader) loadRes(resPath string) {
|
||||
return
|
||||
}
|
||||
baseLoc := res.BaseLoc
|
||||
for i := range res.ColorSpaces.ColorSpace {
|
||||
cs := &res.ColorSpaces.ColorSpace[i]
|
||||
r.colorSpaceCache[cs.ID] = cs
|
||||
}
|
||||
for _, mm := range res.MultiMedias.MultiMedia {
|
||||
if mm.MediaFile != "" {
|
||||
if finalPath := resolveResourcePath(resPath, baseLoc, mm.MediaFile); finalPath != "" {
|
||||
@@ -245,6 +251,9 @@ func (r *Reader) PageContent(page Page) (*PageContent, error) {
|
||||
return nil, fmt.Errorf("failed to unmarshal page content: %w", err)
|
||||
}
|
||||
content.ID = page.ID
|
||||
if content.PageRes != "" {
|
||||
r.loadRes(resolveResourcePath(page.BaseLoc, "", content.PageRes))
|
||||
}
|
||||
return &content, nil
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user