Fonts are not loading from embed.FS
yznts opened this issue · 3 comments
While running oxigen binary (not as docker container), there is an error related to fonts loading (originally reported here).
Serving on ::8000
172.17.0.1 - - [13/Jan/2023:17:21:17 +0000] "GET / HTTP/1.1" 200 15410
172.17.0.1 - - [13/Jan/2023:17:21:17 +0000] "GET /assets/css/tailwind.min.css HTTP/1.1" 200 0
172.17.0.1 - - [13/Jan/2023:17:21:17 +0000] "GET /assets/css/bundle.min.css HTTP/1.1" 200 0
172.17.0.1 - - [13/Jan/2023:17:21:17 +0000] "GET /assets/js/bundle.min.js HTTP/1.1" 200 0
172.17.0.1 - - [13/Jan/2023:17:21:20 +0000] "GET /ui?title=Oxigen%3A+Social+media+image+generator&author=%40yuriizinets&website=github.com%2Fyuriizinets%2Foxigen&logo=https%3A%2F%2Fimgur.com%2FkKUt9Pt.png&background=https%3A%2F%2Fimgur.com%2F8K6rdoZ.png&dim=110 HTTP/1.1" 200 15264
172.17.0.1 - - [13/Jan/2023:17:21:20 +0000] "GET /assets/css/bundle.min.css HTTP/1.1" 200 0
172.17.0.1 - - [13/Jan/2023:17:21:20 +0000] "GET /assets/css/tailwind.min.css HTTP/1.1" 200 0
172.17.0.1 - - [13/Jan/2023:17:21:20 +0000] "GET /assets/js/bundle.min.js HTTP/1.1" 200 0
172.17.0.1 - - [13/Jan/2023:17:21:21 +0000] "GET /ui?title=Oxigen%3A+Social+media+image+generator&author=%40yuriizinets&website=github.com%2Fyuriizinets%2Foxigen&logo=https%3A%2F%2Fimgur.com%2FkKUt9Pt.png&background=https%3A%2F%2Fimgur.com%2F8K6rdoZ.png&dim=110 HTTP/1.1" 200 15264
172.17.0.1 - - [13/Jan/2023:17:21:21 +0000] "GET /assets/css/tailwind.min.css HTTP/1.1" 200 0
172.17.0.1 - - [13/Jan/2023:17:21:21 +0000] "GET /assets/css/bundle.min.css HTTP/1.1" 200 0
172.17.0.1 - - [13/Jan/2023:17:21:21 +0000] "GET /assets/js/bundle.min.js HTTP/1.1" 200 0
2023/01/13 17:21:26 http: panic serving 172.17.0.1:57316: error while reading font file
goroutine 70 [running]:
net/http.(*conn).serve.func1()
/usr/local/go/src/net/http/server.go:1850 +0xbf
panic({0x846680, 0xc76cd0})
/usr/local/go/src/runtime/panic.go:890 +0x262
main.AGenerate({0xc7beb8, 0xc00022a2d0}, 0xc000204c00)
/src/api.generate.go:110 +0x11a5
net/http.HandlerFunc.ServeHTTP(0xc7b858?, {0xc7beb8?, 0xc00022a2d0?}, 0x0?)
/usr/local/go/src/net/http/server.go:2109 +0x2f
github.com/gorilla/handlers.loggingHandler.ServeHTTP({{0xc78b40, 0xc000014070}, {0xc795a0, 0xbfd190}, 0xbfcee0}, {0xc7b858, 0xc0002161c0}, 0xc000204c00)
/go/pkg/mod/github.com/gorilla/handlers@v1.5.1/logging.go:47 +0xef
github.com/gorilla/mux.(*Router).ServeHTTP(0xc00016a0c0, {0xc7b858, 0xc0002161c0}, 0xc00039c900)
/go/pkg/mod/github.com/gorilla/mux@v1.8.0/mux.go:210 +0x1cf
net/http.serverHandler.ServeHTTP({0xc000385e60?}, {0xc7b858, 0xc0002161c0}, 0xc00039c900)
/usr/local/go/src/net/http/server.go:2947 +0x30c
net/http.(*conn).serve(0xc0003bc1e0, {0xc7c440, 0xc00007f8c0})
/usr/local/go/src/net/http/server.go:1991 +0x607
created by net/http.(*Server).Serve
/usr/local/go/src/net/http/server.go:3102 +0x4db
2023/01/13 17:21:28 http: panic serving 172.17.0.1:57306: error while reading font file
goroutine 15 [running]:
net/http.(*conn).serve.func1()
/usr/local/go/src/net/http/server.go:1850 +0xbf
panic({0x846680, 0xc76cd0})
/usr/local/go/src/runtime/panic.go:890 +0x262
main.AGenerate({0xc7beb8, 0xc00022a500}, 0xc000176400)
/src/api.generate.go:110 +0x11a5
net/http.HandlerFunc.ServeHTTP(0xc7b858?, {0xc7beb8?, 0xc00022a500?}, 0x0?)
/usr/local/go/src/net/http/server.go:2109 +0x2f
github.com/gorilla/handlers.loggingHandler.ServeHTTP({{0xc78b40, 0xc000014070}, {0xc795a0, 0xbfd190}, 0xbfcee0}, {0xc7b858, 0xc000216380}, 0xc000176400)
/go/pkg/mod/github.com/gorilla/handlers@v1.5.1/logging.go:47 +0xef
github.com/gorilla/mux.(*Router).ServeHTTP(0xc00016a0c0, {0xc7b858, 0xc000216380}, 0xc000205600)
/go/pkg/mod/github.com/gorilla/mux@v1.8.0/mux.go:210 +0x1cf
net/http.serverHandler.ServeHTTP({0xc0001ac7b0?}, {0xc7b858, 0xc000216380}, 0xc000205600)
/usr/local/go/src/net/http/server.go:2947 +0x30c
net/http.(*conn).serve(0xc0001aa140, {0xc7c440, 0xc00007f8c0})
/usr/local/go/src/net/http/server.go:1991 +0x607
created by net/http.(*Server).Serve
/usr/local/go/src/net/http/server.go:3102 +0x4db
2023/01/13 17:21:31 http: panic serving 172.17.0.1:57292: error while reading font file
goroutine 6 [running]:
net/http.(*conn).serve.func1()
/usr/local/go/src/net/http/server.go:1850 +0xbf
panic({0x846680, 0xc76cd0})
/usr/local/go/src/runtime/panic.go:890 +0x262
main.AGenerate({0xc7beb8, 0xc0000261e0}, 0xc000204200)
/src/api.generate.go:110 +0x11a5
net/http.HandlerFunc.ServeHTTP(0xc7b858?, {0xc7beb8?, 0xc0000261e0?}, 0x0?)
/usr/local/go/src/net/http/server.go:2109 +0x2f
github.com/gorilla/handlers.loggingHandler.ServeHTTP({{0xc78b40, 0xc000014070}, {0xc795a0, 0xbfd190}, 0xbfcee0}, {0xc7b858, 0xc000216000}, 0xc000204200)
/go/pkg/mod/github.com/gorilla/handlers@v1.5.1/logging.go:47 +0xef
github.com/gorilla/mux.(*Router).ServeHTTP(0xc00016a0c0, {0xc7b858, 0xc000216000}, 0xc000205100)
/go/pkg/mod/github.com/gorilla/mux@v1.8.0/mux.go:210 +0x1cf
net/http.serverHandler.ServeHTTP({0xc00007f9b0?}, {0xc7b858, 0xc000216000}, 0xc000205100)
/usr/local/go/src/net/http/server.go:2947 +0x30c
net/http.(*conn).serve(0xc000001e00, {0xc7c440, 0xc00007f8c0})
/usr/local/go/src/net/http/server.go:1991 +0x607
created by net/http.(*Server).Serve
/usr/local/go/src/net/http/server.go:3102 +0x4db
2023/01/13 17:21:34 http: panic serving 172.17.0.1:57298: error while reading font file
goroutine 14 [running]:
net/http.(*conn).serve.func1()
/usr/local/go/src/net/http/server.go:1850 +0xbf
panic({0x846680, 0xc76cd0})
/usr/local/go/src/runtime/panic.go:890 +0x262
main.AGenerate({0xc7beb8, 0xc00022a2d0}, 0xc000204400)
/src/api.generate.go:110 +0x11a5
net/http.HandlerFunc.ServeHTTP(0xc7b858?, {0xc7beb8?, 0xc00022a2d0?}, 0x0?)
/usr/local/go/src/net/http/server.go:2109 +0x2f
github.com/gorilla/handlers.loggingHandler.ServeHTTP({{0xc78b40, 0xc000014070}, {0xc795a0, 0xbfd190}, 0xbfcee0}, {0xc7b858, 0xc0002160e0}, 0xc000204400)
/go/pkg/mod/github.com/gorilla/handlers@v1.5.1/logging.go:47 +0xef
github.com/gorilla/mux.(*Router).ServeHTTP(0xc00016a0c0, {0xc7b858, 0xc0002160e0}, 0xc000205700)
/go/pkg/mod/github.com/gorilla/mux@v1.8.0/mux.go:210 +0x1cf
net/http.serverHandler.ServeHTTP({0xc0001ac6c0?}, {0xc7b858, 0xc0002160e0}, 0xc000205700)
/usr/local/go/src/net/http/server.go:2947 +0x30c
net/http.(*conn).serve(0xc0001aa0a0, {0xc7c440, 0xc00007f8c0})
/usr/local/go/src/net/http/server.go:1991 +0x607
created by net/http.(*Server).Serve
/usr/local/go/src/net/http/server.go:3102 +0x4db
2023/01/13 17:21:36 http: panic serving 172.17.0.1:57318: error while reading font file
goroutine 55 [running]:
net/http.(*conn).serve.func1()
/usr/local/go/src/net/http/server.go:1850 +0xbf
panic({0x846680, 0xc76cd0})
/usr/local/go/src/runtime/panic.go:890 +0x262
main.AGenerate({0xc7beb8, 0xc0000262d0}, 0xc000176300)
/src/api.generate.go:110 +0x11a5
net/http.HandlerFunc.ServeHTTP(0xc7b858?, {0xc7beb8?, 0xc0000262d0?}, 0x0?)
/usr/local/go/src/net/http/server.go:2109 +0x2f
github.com/gorilla/handlers.loggingHandler.ServeHTTP({{0xc78b40, 0xc000014070}, {0xc795a0, 0xbfd190}, 0xbfcee0}, {0xc7b858, 0xc000216000}, 0xc000176300)
/go/pkg/mod/github.com/gorilla/handlers@v1.5.1/logging.go:47 +0xef
github.com/gorilla/mux.(*Router).ServeHTTP(0xc00016a0c0, {0xc7b858, 0xc000216000}, 0xc000176100)
/go/pkg/mod/github.com/gorilla/mux@v1.8.0/mux.go:210 +0x1cf
net/http.serverHandler.ServeHTTP({0xc0001ad320?}, {0xc7b858, 0xc000216000}, 0xc000176100)
/usr/local/go/src/net/http/server.go:2947 +0x30c
net/http.(*conn).serve(0xc0003bc5a0, {0xc7c440, 0xc00007f8c0})
/usr/local/go/src/net/http/server.go:1991 +0x607
created by net/http.(*Server).Serve
/usr/local/go/src/net/http/server.go:3102 +0x4db
2023/01/13 17:21:38 http: panic serving 172.17.0.1:38978: error while reading font file
goroutine 160 [running]:
net/http.(*conn).serve.func1()
/usr/local/go/src/net/http/server.go:1850 +0xbf
panic({0x846680, 0xc76cd0})
/usr/local/go/src/runtime/panic.go:890 +0x262
main.AGenerate({0xc7beb8, 0xc00022a280}, 0xc000282200)
/src/api.generate.go:110 +0x11a5
net/http.HandlerFunc.ServeHTTP(0xc7b858?, {0xc7beb8?, 0xc00022a280?}, 0x0?)
/usr/local/go/src/net/http/server.go:2109 +0x2f
github.com/gorilla/handlers.loggingHandler.ServeHTTP({{0xc78b40, 0xc000014070}, {0xc795a0, 0xbfd190}, 0xbfcee0}, {0xc7b858, 0xc0002160e0}, 0xc000282200)
/go/pkg/mod/github.com/gorilla/handlers@v1.5.1/logging.go:47 +0xef
github.com/gorilla/mux.(*Router).ServeHTTP(0xc00016a0c0, {0xc7b858, 0xc0002160e0}, 0xc000176200)
/go/pkg/mod/github.com/gorilla/mux@v1.8.0/mux.go:210 +0x1cf
net/http.serverHandler.ServeHTTP({0xc0001ac0c0?}, {0xc7b858, 0xc0002160e0}, 0xc000176200)
/usr/local/go/src/net/http/server.go:2947 +0x30c
net/http.(*conn).serve(0xc0001aa0a0, {0xc7c440, 0xc00007f8c0})
/usr/local/go/src/net/http/server.go:1991 +0x607
created by net/http.(*Server).Serve
/usr/local/go/src/net/http/server.go:3102 +0x4db
Self Plug: Consider using my fonts package https://github.com/go-swiss/fonts
Makes embedding fonts a breeze and if you ever want to support more fonts, it makes that easy too.
@stephenafamo thank you for following up!
Main issue in this case is LoadFontFace
(api.generate.go
line 138), which loads font with a given path (not using embed fs).
I'll need to implement a custom function to load font face from embed fs into the given context, or just implement some workaround/wrapper for existing one.
After a project refactor, I'm not going to include plain binary releases.
Going to provide instructions on attaching own fonts in the docs.