From 30c914f65cc81ee1d3dfd3892293ac479112bbff Mon Sep 17 00:00:00 2001 From: Jan De Dobbeleer Date: Sun, 22 Dec 2024 20:26:42 +0100 Subject: [PATCH] fix(image): set font cache before usage --- src/font/cli.go | 6 +++++- src/image/image.go | 2 ++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/font/cli.go b/src/font/cli.go index e9a32eefccb7..1f96c99e5ffe 100644 --- a/src/font/cli.go +++ b/src/font/cli.go @@ -350,6 +350,10 @@ func (m *main) View() string { return "" } +func SetCache(c cache_.Cache) { + cache = c +} + func Run(font string, ch cache_.Cache, root bool, zipFolder string) { main := &main{ 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) if _, err := program.Run(); err != nil { diff --git a/src/image/image.go b/src/image/image.go index 9580d2066223..10c428433511 100644 --- a/src/image/image.go +++ b/src/image/image.go @@ -145,6 +145,8 @@ func (ir *Renderer) Init(env runtime.Environment) error { ir.cleanContent() + font_.SetCache(env.Cache()) + if err := ir.loadFonts(); err != nil { return &ConnectionError{reason: err.Error()} }