Skip to content

linux-rust : Compiling from source archive fails because of missing DejaVuSans.ttf #401

@d0tiKs

Description

@d0tiKs

When trying to build from source using the tar.gz avaiable to download I got this message :

❯ cargo build -r 2>| grep error -A 8
error: couldn't read `src/ui/../../assets/font/DejaVuSans.ttf`: No such file or directory (os error 2)
   --> src/ui/tray.rs:176:21
    |
176 |     let font_data = include_bytes!("../../assets/font/DejaVuSans.ttf");
    |                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

warning: unused import: `crate::bluetooth::att::ATTManager`
 --> src/devices/airpods.rs:3:5
  |
--
error: could not compile `librepods` (bin "librepods") due to 1 previous error; 13 warnings emitted

I think the path to the font asset should be different, putting the font availability as a requirement and using the standard path for font /usr/share/fonts/TTF/ could be a way to fix it (in linux-rust/src/ui/tray.rs ).

fn generate_icon(text: &str, text_mode: bool, charging: bool) -> Icon {
    use ab_glyph::{FontRef, PxScale};
    use image::{ImageBuffer, Rgba};
    use imageproc::drawing::draw_text_mut;

    let width = 64;
    let height = 64;

    let mut img = ImageBuffer::from_fn(width, height, |_, _| Rgba([0u8, 0u8, 0u8, 0u8]));

-    let font_data = include_bytes!("../../assets/font/DejaVuSans.ttf");
+    let font_data = include_bytes!("/usr/share/fonts/TTF/DejaVuSans.ttf");
    let font = match FontRef::try_from_slice(font_data) {
        Ok(f) => f,
        Err(_) => {
            return Icon {
                width: width as i32,
                height: height as i32,
                data: vec![0u8; (width * height * 4) as usize],
            };
        }
    };

Another way would be to bundle the font in the archive, which perhaps seems the best.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions