use std::collections::BTreeMap;
use rocketsplash_formats::{
FontAtlas, FontMeta, GlyphData, GlyphVariants, RenderMode, StyleFlags, FONT_ATLAS_VERSION,
};
use crate::font::Font;
#[test]
fn drop_shadow_defaults_expand_buffer() {
let font = make_font();
let builder = font.render("A").drop_shadow();
let buffer = builder.build_buffer().expect("buffer builds");
assert_eq!(buffer.width, 2);
assert_eq!(buffer.height, 2);
let base = buffer.cell(0, 0).expect("base cell");
assert_eq!(base.ch, 'A');
let shadow = buffer.cell(1, 1).expect("shadow cell");
assert_eq!(shadow.ch, 'A');
assert!(shadow.fg.is_some());
}
fn make_font() -> Font {
let glyph = make_glyph('A');
let variants = GlyphVariants {
base: glyph,
bold: None,
italic: None,
bold_italic: None,
reverse: None,
};
let mut glyphs = BTreeMap::new();
glyphs.insert('A', variants);
let atlas = FontAtlas {
version: FONT_ATLAS_VERSION,
meta: FontMeta {
font_name: "Test".to_string(),
font_size: 12.0,
created_at: 0,
editor_version: "test".to_string(),
},
glyphs,
line_height: 1,
mode: RenderMode::Braille,
available_styles: StyleFlags::empty(),
};
let bytes = rmp_serde::to_vec(&atlas).expect("serialize atlas");
Font::from_bytes(&bytes).expect("load font")
}
fn make_glyph(ch: char) -> GlyphData {
GlyphData {
chars: ch.to_string(),
width: 1,
height: 1,
opacity: Some(vec![255]),
}
}