Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using the master branch as a dependency and running the example is broken on M2. #36

Open
asibahi opened this issue Jan 5, 2024 · 1 comment

Comments

@asibahi
Copy link
Contributor

asibahi commented Jan 5, 2024

Hello.

My machine is a MacBook Air M2.

I am on the latest Rust release (1.75.0).

This is my dependencies section in Cargo.toml

[dependencies]
harfbuzz_rs = { git = "https://github.com/harfbuzz/harfbuzz_rs.git" }

I am using the example code given in the crate. Regardless, this is my code:

use std::error::Error;
use harfbuzz_rs::*;

fn main() -> Result<(), Box<dyn Error>> {
    let path =
        "/Users/abdulrahmansibahi/Documents/rust/mimiron/mimiron/fonts/YanoneKaffeesatz-Medium.ttf";
    let index = 0; //< face index in the font file
    let face = Face::from_file(path, index)?;
    let font = Font::new(face);

    let buffer = UnicodeBuffer::new().add_str("Hello World!");
    let output = shape(&font, buffer, &[]);

    let positions = output.get_glyph_positions();
    let infos = output.get_glyph_infos();

    for (position, info) in positions.iter().zip(infos) {
        let gid = info.codepoint;
        let cluster = info.cluster;
        let x_advance = position.x_advance;
        let x_offset = position.x_offset;
        let y_offset = position.y_offset;        

        println!(
            "gid: {:?}. cluster: {:?}. x_advance: {:?}, x_offset: {:?} y_offset: {:?}",
            gid, cluster, x_advance, x_offset, y_offset
        );
    }

    Ok(())
}

And this is the error I get :

error.txt

I asked in the Rust Community Discord server and it apparently works on other, non-Apple, systems. I haven't tried myself as I .. don't have other systems.

This same code works on the Crates.io version.

Edit: This is the last good commit that works for me : 15d1c2a , pre removing the harfbuzz_sys crate as a dependency.

@asibahi
Copy link
Contributor Author

asibahi commented Apr 12, 2024

Tried cloning the repo into my machine instead of linking from GitHub, and faced the same issue.

A bit of googling about the not found symbols, I found this Stack Overflow Answer, which seems related. but I don't know enough on how to solve it myself. Edit2? I found that the reason is that OS X on ARM puts the Core Foundation libraries somewhere else. The meson file handles that, but I could not figure out how to translate the conditions into build.rs or how to invoke the meson file from there.

Edit: commenting out this part in build.rs made it compile and run the example successfully:

    if target.contains("apple") {
        cfg.define("HAVE_CORETEXT", "1");
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant