Skip to content

Face::set_variation change in behaviour #134

@alexheretic

Description

@alexheretic

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions