Skip to main content

warn_sprite_needs_span

Function warn_sprite_needs_span 

Source
pub fn warn_sprite_needs_span(
    seen: &mut BTreeSet<char>,
    glyph: char,
    sprite: (u32, u32),
    cell: (u32, u32),
) -> bool
Expand description

Warns, at most once per glyph, that glyph’s sprite is larger than one cell but was drawn without a span reserving the cells it covers.

For backend implementors: both graphical backends call this from their sprite blit, so the diagnostic and the fix it names are identical on each. Such a sprite still draws at its natural size, but its pixels land in neighbouring cells that go on painting their own background and glyph over it, which is a confusing thing to debug from the rendered output alone.

sprite and cell are (width, height) in unscaled pixels; a sprite fitting within cell on both axes is silent. seen is caller-owned state so a redraw loop reports each offending glyph once rather than every frame; entries are only ever added.

Returns whether a warning was emitted, which is always false in a build that compiles diagnostics out: the size comparison, the seen bookkeeping, and the message all sit inside dev_only!, so a release build does none of them. See BuildMode.