//! Official KVT wordmark for the title bar. Kept in its own file so the weekly //! upstream merge does not have to touch the logo bytes. use crate::theme::Shade; const LOGO: &[u8] = include_bytes!("../../app/assets/brand/kvt-logo.png"); const LOGO_WIT: &[u8] = include_bytes!("../../app/assets/brand/kvt-logo-wit.png"); /// Display size of the wordmark in the title bar, including the clear space /// baked into the PNG (a quarter of the ink height, per the house style). pub const TITLE_LOGO_HEIGHT: f32 = 32.; pub const TITLE_LOGO_WIDTH: f32 = 94.; /// Colour logo on light grounds (the original logo belongs on white). White logo /// on dark and high-contrast grounds, as `logo-kvt-wit.png` in the house style. pub fn title_logo_png(shade: Shade) -> Option<&'static [u8]> { Some(if shade.is_dark() { LOGO_WIT } else { LOGO }) } #[cfg(test)] mod tests { use super::*; use crate::theme::Shade; #[test] fn both_wordmarks_are_png() { for bytes in [LOGO, LOGO_WIT] { assert!(bytes.starts_with(b"\x89PNG"), "not a png"); } assert_ne!(title_logo_png(Shade::Light), title_logo_png(Shade::Dark)); assert_eq!( title_logo_png(Shade::Dark), title_logo_png(Shade::HighContrast) ); } #[test] fn the_display_size_matches_the_png_aspect() { // IHDR width and height sit at bytes 16..24 of a PNG. let width = u32::from_be_bytes(LOGO[16..20].try_into().unwrap()); let height = u32::from_be_bytes(LOGO[20..24].try_into().unwrap()); let aspect = (width as f32) / (height as f32); let display = TITLE_LOGO_WIDTH / TITLE_LOGO_HEIGHT; assert!( (aspect - display).abs() < 0.02, "{width}x{height} aspect {aspect} vs display {display}" ); let wit_w = u32::from_be_bytes(LOGO_WIT[16..20].try_into().unwrap()); let wit_h = u32::from_be_bytes(LOGO_WIT[20..24].try_into().unwrap()); assert_eq!((width, height), (wit_w, wit_h)); } }