fix(engine): fall through to system default font on unmatched family
CI / Test & Lint (push) Failing after 5s
CI / Release Build (push) Has been skipped

Replaces the previous LogPlugin-filter approach (which suppresses the
warn message) with a fix at the source: a custom usvg FontResolver
that appends `sans-serif` and `serif` to every family-lookup query.

usvg's default selector queries fontdb with [SVG-requested families,
Serif] and emits `log::warn!("No match for '{family}'")` when the
query returns None. On systems without the SVG's named family (Arial
on Linux, etc.), every text node logs a warn even though the system
has perfectly good fonts available — the warn is a false negative
because fontdb's named-family lookup is exact-match only.

The new resolver appends both `Family::SansSerif` and `Family::Serif`
to the query, both resolved by fontdb (via fontconfig on Linux or
built-in defaults elsewhere) to whatever the system has installed.
The query now finds *some* face on any reasonably configured machine,
so `id.is_none()` is never true and the warn branch never fires. The
visible behaviour: SVGs that request unavailable named families now
silently use the system's default sans-serif font.

Reverts the LogPlugin filter from main.rs — silencing warns at the
log level was the wrong layer; fixing the lookup is.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
funman300
2026-05-01 18:41:02 +00:00
parent 78cf30e906
commit efa063fb8f
2 changed files with 76 additions and 13 deletions
-13
View File
@@ -100,19 +100,6 @@ fn main() {
.set(bevy::asset::AssetPlugin {
file_path: "../assets".to_string(),
..default()
})
// The bundled hayeah card SVGs declare `font-family="Arial"`
// for rank/suit text. usvg compares family names exactly,
// so on systems without Arial installed (every Linux
// distro by default) it bridges a `log::warn!` per text
// node into our tracing output — 50+ lines per game on
// launch. The substitution path in `svg_loader::shared_fontdb`
// already resolves the glyphs to whatever sans-serif the
// user does have; the warn is purely informational and
// dropping it leaves real errors visible.
.set(bevy::log::LogPlugin {
filter: format!("{},usvg::text=error", bevy::log::DEFAULT_FILTER),
..default()
}),
)
.add_plugins(AssetSourcesPlugin)