11 breaking releases

0.12.0 Jan 2, 2019
0.11.0 Dec 29, 2018
0.10.0 Dec 27, 2018
0.7.0 Jun 17, 2018
Download history 4/week @ 2022-01-25 1/week @ 2022-02-01 2/week @ 2022-02-08 2/week @ 2022-02-15 17/week @ 2022-02-22 2/week @ 2022-03-01 2/week @ 2022-03-08 54/week @ 2022-03-15 42/week @ 2022-03-22 3/week @ 2022-03-29 4/week @ 2022-04-05 2/week @ 2022-04-12 3/week @ 2022-04-19 94/week @ 2022-04-26 93/week @ 2022-05-03 199/week @ 2022-05-10

389 downloads per month
Used in cff

Apache-2.0

11KB
186 lines

sfnt

crates.io docs.rs travis-ci.com

A zero-allocation SFNT parser.

Released under the Apache License 2.0.

Supported on Rust 1.31.0 and later.

Example

use std::fs::{File};
use std::io::{Read};

use sfnt::{Record, Sfnt, Tag};

fn main() {
    // Read the font file into memory.
    let mut file = File::open("tests/resources/OpenSans-Italic.ttf").unwrap();
    let mut bytes = vec![];
    file.read_to_end(&mut bytes).unwrap();

    // Parse the font file and find one of the tables in the font file.
    let sfnt = Sfnt::parse(&bytes).unwrap();
    let (record, bytes) = sfnt.find(b"head").unwrap();

    assert_eq!(record, Record {
        tag: Tag(b"head"),
        checksum: 4165466467,
        offset: 316,
        length: 54,
    });

    assert_eq!(bytes.len(), 54);
}

Dependencies

~1.5MB
~43K SLoC