sqshq/sampler · error
Failed to load the font:
Error message
Failed to load the font:
What it means
NewAsciiBox panics when the embedded font file (font name + ".flf") cannot be loaded from the bundled assets. The component requires one of the known figlet-style fonts embedded in the binary, so an unknown font name in the config is a hard startup failure for that component.
Source
Thrown at component/asciibox/asciibox.go:36
*data.Consumer
alert *data.Alert
ascii string
style ui.Style
render *fl.AsciiRender
options *fl.RenderOptions
palette console.Palette
}
const asciiFontExtension = ".flf"
func NewAsciiBox(c config.AsciiBoxConfig, palette console.Palette) *AsciiBox {
options := fl.NewRenderOptions()
options.FontName = string(*c.Font)
fontStr, err := asset.Asset(options.FontName + asciiFontExtension)
if err != nil {
panic("Failed to load the font: " + err.Error())
}
render := fl.NewAsciiRender()
_ = render.LoadBindataFont(fontStr, options.FontName)
color := c.Color
if color == nil {
color = &palette.BaseColor
}
box := AsciiBox{
Block: component.NewBlock(c.Title, *c.Border, palette),
Consumer: data.NewConsumer(),
style: ui.NewStyle(*color),
render: render,
options: options,
palette: palette,
}View on GitHub (pinned to 9bc7ba732d)
Solutions
- Set the font to one of the supported built-in names (e.g. standard, big, block, shadow...) exactly as shipped
- Check the embedded asset list / repo fonts directory for valid font file names
- Wrap NewAsciiBox/startAll with recover or pre-validate the font value before constructing the component
- Add the desired .flf font to the embedded assets if a custom font is genuinely needed
Example fix
// before font: BigFinale color: red // after font: standard # supported embedded font color: red
Defensive patterns
Strategy: validation
Validate before calling
var supportedFonts = map[string]bool{"standard": true, "big": true, "block": true, "shadow": true}
if !supportedFonts[strings.ToLower(cfg.Font)] { cfg.Font = ptr("standard") } Type guard
func fontAvailable(name string) bool {
_, err := asset.Asset(name + ".flf")
return err == nil
} Try / catch
func newBoxSafe(cfg *Cfg) (box *asciibox.AsciiBox, err error) {
defer func() { if r := recover(); r != nil { err = fmt.Errorf("ascii box init failed: %v", r) } }()
return asciibox.NewAsciiBox(cfg), nil
} Prevention
- Validate font names against the embedded list at config load
- Keep font values in sync with the shipped .flf assets
- Fail fast at startup with a clear message listing valid fonts
When it happens
Trigger: Configuring an ascii-box component with a font value whose <font>.flf is not present in the embedded asset store; asset.Asset(options.FontName+asciiFontExtension) returns an error and the code panics.
Common situations: Typo in the YAML font field; copying a config from another project using different font names; expecting a custom font to be available when only built-in fonts are embedded.
Understand the failure class
Background: "File not found" and ENOENT errors: why libraries can't find a file that should exist — this error's family across 50 libraries.
Related errors
- panic(err)
- Failed to find component type %v with title %v
- Specified theme is not supported: %v
- errorText.String()
- PTY mode is not supported on Windows
AI-assisted analysis of sqshq/sampler@9bc7ba732d (2026-09-06).
Data as JSON: /api/errors/2e9311cb62812e16.
Report an issue: GitHub.