diff --git a/Cargo.lock b/Cargo.lock index 97e1db0..33876cc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1668,7 +1668,7 @@ dependencies = [ [[package]] name = "mpd_info_screen" -version = "0.3.1" +version = "0.3.2" dependencies = [ "bindgen", "freetype", diff --git a/Cargo.toml b/Cargo.toml index acfe588..91f1ca5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "mpd_info_screen" -version = "0.3.1" +version = "0.3.2" edition = "2018" description = "Displays info on currently playing music from an MPD daemon" license = "MIT" diff --git a/README.md b/README.md index b3bca25..f778c20 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ installed already). # Usage - mpd_info_screen 0.3.1 + mpd_info_screen 0.3.2 USAGE: mpd_info_screen [FLAGS] [OPTIONS] [port] diff --git a/src/display.rs b/src/display.rs index c176698..afe563a 100644 --- a/src/display.rs +++ b/src/display.rs @@ -740,6 +740,11 @@ impl EventHandler for MPDDisplay { &mut self.loaded_fonts, ctx, ); + log( + format!("loaded_fonts size is {}", self.loaded_fonts.len()), + debug_log::LogState::Debug, + self.opts.log_level, + ); } } else { self.dirty_flag diff --git a/src/unicode_support.rs b/src/unicode_support.rs index eede2ef..f3d6de0 100644 --- a/src/unicode_support.rs +++ b/src/unicode_support.rs @@ -3,3 +3,17 @@ mod freetype; pub use self::freetype::font_has_char; pub use fontconfig::{get_matching_font_from_char, get_matching_font_from_str}; + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_ascii_verify() { + let fetched_path = + get_matching_font_from_char('a').expect("Should be able to find match for 'a'"); + if !font_has_char('a', &fetched_path).expect("Should be able to check font for 'a'") { + panic!("fetched font does not have 'a'"); + } + } +} diff --git a/src/unicode_support/freetype.rs b/src/unicode_support/freetype.rs index 4eb07b7..8e324c0 100644 --- a/src/unicode_support/freetype.rs +++ b/src/unicode_support/freetype.rs @@ -27,7 +27,7 @@ mod ffi { pub fn new() -> Option { unsafe { let mut library_ptr: FT_Library = 0 as FT_Library; - if FT_Init_FreeType(&mut library_ptr) != 0 { + if FT_Init_FreeType(&mut library_ptr) == 0 { Some(FTLibrary { library: library_ptr, }) @@ -98,7 +98,7 @@ mod ffi { } impl FTFaces { - pub fn new(library: &FTLibrary, args: &mut FTOpenArgs) -> Result { + pub fn new(library: &FTLibrary, args: &mut FTOpenArgs) -> Result { let mut faces = FTFaces { faces: Vec::new() }; unsafe { let mut face: FT_Face = 0 as FT_Face; @@ -111,7 +111,7 @@ mod ffi { ); if result != 0 { FT_Done_Face(face); - return Err(()); + return Err(String::from("Failed to get number of faces")); } let count = (*face).num_faces; @@ -124,7 +124,7 @@ mod ffi { ); if result != 0 { FT_Done_Face(face); - return Err(()); + return Err(String::from("Failed to fetch face")); } faces.faces.push(face); } @@ -150,8 +150,8 @@ mod ffi { } } -pub fn font_has_char(c: char, font_path: &Path) -> Result { - let library = ffi::FTLibrary::new().ok_or(())?; +pub fn font_has_char(c: char, font_path: &Path) -> Result { + let library = ffi::FTLibrary::new().ok_or(String::from("Failed to get FTLibrary"))?; let mut args = ffi::FTOpenArgs::new_with_path(font_path); let faces = ffi::FTFaces::new(&library, &mut args)?;