fix(image): set font cache before usage

This commit is contained in:
Jan De Dobbeleer 2024-12-22 20:26:42 +01:00 committed by Jan De Dobbeleer
parent caece11225
commit da74c2b27c
2 changed files with 7 additions and 1 deletions

View file

@ -350,6 +350,10 @@ func (m *main) View() string {
return "" return ""
} }
func SetCache(c cache_.Cache) {
cache = c
}
func Run(font string, ch cache_.Cache, root bool, zipFolder string) { func Run(font string, ch cache_.Cache, root bool, zipFolder string) {
main := &main{ main := &main{
system: root, system: root,
@ -360,7 +364,7 @@ func Run(font string, ch cache_.Cache, root bool, zipFolder string) {
}, },
} }
cache = ch SetCache(ch)
program = tea.NewProgram(main) program = tea.NewProgram(main)
if _, err := program.Run(); err != nil { if _, err := program.Run(); err != nil {

View file

@ -145,6 +145,8 @@ func (ir *Renderer) Init(env runtime.Environment) error {
ir.cleanContent() ir.cleanContent()
font_.SetCache(env.Cache())
if err := ir.loadFonts(); err != nil { if err := ir.loadFonts(); err != nil {
return &ConnectionError{reason: err.Error()} return &ConnectionError{reason: err.Error()}
} }