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

Face::set_variation change in behaviour #134

Open
alexheretic opened this issue Oct 22, 2023 · 1 comment
Open

Face::set_variation change in behaviour #134

alexheretic opened this issue Oct 22, 2023 · 1 comment

Comments

@alexheretic
Copy link

alexheretic commented Oct 22, 2023

I noticed Face::set_variation now returns Some(()) even when the face does not have the axis since v0.20.0.

If this is intended the docs should be amended.

Returns None when face is not variable or doesn't have such axis.

Reproduce

// [dependencies]
// ttf-parser19 = { version = "0.19", package = "ttf-parser" }
// ttf-parser = "0.20"

const VAR_FONT: &[u8] = include_bytes!("../Cantarell-VF.otf");

fn main() {
    let mut face = ttf_parser19::Face::parse(VAR_FONT, 0).unwrap();
    dbg!(face.set_variation(ttf_parser19::Tag::from_bytes(b"wght"), 600.0)); // Some(())
    dbg!(face.set_variation(ttf_parser19::Tag::from_bytes(b"foob"), 200.0)); // None
    dbg!(face.set_variation(ttf_parser19::Tag::from_bytes(b"barr"), 200.0)); // None

    let mut face = ttf_parser::Face::parse(VAR_FONT, 0).unwrap();
    dbg!(face.set_variation(ttf_parser::Tag::from_bytes(b"wght"), 600.0)); // Some(())
    dbg!(face.set_variation(ttf_parser::Tag::from_bytes(b"foob"), 200.0)); // Some(())
    dbg!(face.set_variation(ttf_parser::Tag::from_bytes(b"barr"), 200.0)); // Some(())
}

Using Cantarell-VF.otf.

@RazrFalcon
Copy link
Owner

Yes, my bad. It should not return anything now. You have to use face.variation_axes() to check for available tags beforehand.

This mimics the harfbuzz API: https://github.com/harfbuzz/harfbuzz/blob/b0150ffd05523c7cef9b3c91a8d6050177fceda3/src/hb-font.cc#L2658-L2676

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

2 participants