]> git.seodisparate.com - mpd_info_screen/commitdiff
Fix always failing freetype call, version 0.3.2 0.3.2
authorStephen Seo <seo.disparate@gmail.com>
Mon, 1 Aug 2022 05:19:23 +0000 (14:19 +0900)
committerStephen Seo <seo.disparate@gmail.com>
Mon, 1 Aug 2022 05:19:23 +0000 (14:19 +0900)
Cargo.lock
Cargo.toml
README.md
src/display.rs
src/unicode_support.rs
src/unicode_support/freetype.rs

index 97e1db0ce97e637c2d3db878ad2e83a3956463b2..33876cc3020ca05d12b3761f5968ad2cbe8d8a12 100644 (file)
@@ -1668,7 +1668,7 @@ dependencies = [
 
 [[package]]
 name = "mpd_info_screen"
-version = "0.3.1"
+version = "0.3.2"
 dependencies = [
  "bindgen",
  "freetype",
index acfe588693710441ec450bc3a4a7f1263ede7164..91f1ca5817108b169f5fcd645dabba66311d28b0 100644 (file)
@@ -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"
index b3bca2549e06c873ec0f2b6285ba713de0a7bc8e..f778c20beb2c83ccd870aecbe83901f60fa75228 100644 (file)
--- 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] <host> [port]
index c1766983842cb95abebdbc2663c9f21e4459fb6d..afe563a9df2f162fe03409b72a7e5a90157a06b9 100644 (file)
@@ -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
index eede2effeccc0e9b0ac6985465465f750619f1f5..f3d6de0a194c4e78b1ad37407a36e799968a1b0a 100644 (file)
@@ -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'");
+        }
+    }
+}
index 4eb07b7be1a8f1f608faf3823b033e75b83582a9..8e324c09ea76315d320e9062748d06dae4c1d822 100644 (file)
@@ -27,7 +27,7 @@ mod ffi {
         pub fn new() -> Option<FTLibrary> {
             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<FTFaces, ()> {
+        pub fn new(library: &FTLibrary, args: &mut FTOpenArgs) -> Result<FTFaces, String> {
             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<bool, ()> {
-    let library = ffi::FTLibrary::new().ok_or(())?;
+pub fn font_has_char(c: char, font_path: &Path) -> Result<bool, String> {
+    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)?;