librepods-org / librepods-org/librepods

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

Open
#401 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Kotlin
Stars
29.9k
Forks
1.7k
PR merge metrics
No merged PRs in 30d

Description

When trying to build from source using the tar.gz available 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.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with linux-rust/src/ui/tray.rs and reproduce the failure using cargo build -r from the downloadable source archive. Check whether assets/font/DejaVuSans.ttf is included in the archive and how the font is referenced. Done means the archive builds successfully without requiring an unavailable relative asset or an unspecified system path.

Written by the indexing model from the issue text.

Assessment

Tech stack
linux, rust
Domain
build-system
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.