bug(assets): assert!() on bundled font parse in svg_loader.rs — startup crash risk #58

Closed
opened 2026-05-28 01:50:33 +00:00 by funman300 · 0 comments
Owner

Bug

solitaire_engine/src/assets/svg_loader.rs calls shared_fontdb() which contains an assert!() when parsing the bundled FiraMono font bytes. If the embedded bytes are ever corrupted (truncated binary, bad asset pack) the game panics at startup with no recovery path.

Affected file

solitaire_engine/src/assets/svg_loader.rs

Fix

Replace the assert!() with a Result-returning function and log a warning + fall back to system fonts if the bundled font fails to parse:

match db.load_font_data(FIRA_MONO_BYTES.to_vec()) {
    Ok(_) => {},
    Err(e) => {
        warn!("Failed to load bundled FiraMono font: {e}. SVG text may render incorrectly.");
    }
}

Relevant rule

CLAUDE.md §2.3: NO panic!() in runtime/game logic

## Bug `solitaire_engine/src/assets/svg_loader.rs` calls `shared_fontdb()` which contains an `assert!()` when parsing the bundled FiraMono font bytes. If the embedded bytes are ever corrupted (truncated binary, bad asset pack) the game panics at startup with no recovery path. ## Affected file `solitaire_engine/src/assets/svg_loader.rs` ## Fix Replace the `assert!()` with a `Result`-returning function and log a warning + fall back to system fonts if the bundled font fails to parse: ```rust match db.load_font_data(FIRA_MONO_BYTES.to_vec()) { Ok(_) => {}, Err(e) => { warn!("Failed to load bundled FiraMono font: {e}. SVG text may render incorrectly."); } } ``` ## Relevant rule CLAUDE.md §2.3: NO `panic!()` in runtime/game logic
funman300 added the bugcorrectness labels 2026-05-28 01:50:33 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: funman300/Ferrous-Solitaire#58