strings

Attribute Macro strings 

Source
#[strings]
Expand description

Collects string literals for rewriting mplus! macro invocations prior to their expansion.

This attribute should be applied to the item that contains both the string literals that appear in Text drawables and the mplus! macro that provides the bitmap font in the Text’s character style.

Use #[strings::skip] to exclude string literals or blocks from the output of strings, and apply #[strings::emit] to the macro invocations that you want to modify to have additional input — the string literals that have been collected; appended as a single slice literal expression.

§Examples

#[mplusfonts::strings]
pub fn main() -> Result<(), Infallible> {
    let mut display: SimulatorDisplay<Rgb888> = SimulatorDisplay::new(Size::new(120, 120));

    #[strings::emit]
    let bitmap_font = mplus!(2, 480, 16, true, 4, 8, /* will inject ["It works!"] here */);

    let character_style = BitmapFontStyle::new(&bitmap_font, Rgb888::new(0, 210, 255));

    Text::new("It works!", Point::new(0, 120), character_style).draw(&mut display)?;

    let output_settings = OutputSettingsBuilder::new().scale(6).pixel_spacing(2).build();

    #[strings::skip]
    Window::new("Simulator", &output_settings).show_static(&display);

    Ok(())
}