fix(engine): fall through to system default font on unmatched family
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:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user