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

[Fixes #105] Treat regular font as a one element collection when parsing #106

Merged
merged 3 commits into from
Oct 1, 2022

Conversation

Pietrek14
Copy link
Contributor

When parsing a font that is not a collection, a check is performed that returns a FaceParsingError::FaceIndexOutOfBounds error if the index is not zero. It's a breaking change, but it's not hard to migrate to the new version.

@RazrFalcon
Copy link
Owner

Thanks. The test should be in tests/tables/main.rs. And there is no need to include the font file itself as well. The header part should be enough. Like this:

#[test]
fn font_index_overflow_on_regular_font() {
    use Unit::*;
    let data = convert(&[
        Raw(&[0x00, 0x01, 0x00, 0x00]), // magic
        UInt16(0),                      // numTables
        UInt16(0),                      // searchRange
        UInt16(0),                      // entrySelector
        UInt16(0),                      // rangeShift
    ]);

    assert_eq!(fonts_in_collection(&data), None);
    assert_eq!(
        Face::parse(&data, 1).unwrap_err(),
        FaceParsingError::FaceIndexOutOfBounds
    );
}

@RazrFalcon RazrFalcon merged commit d9e71a1 into RazrFalcon:master Oct 1, 2022
@RazrFalcon
Copy link
Owner

Thanks!

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

Successfully merging this pull request may close these issues.

None yet

2 participants