[][src]Crate sfnt

A zero-allocation SFNT parser.

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);
}

Structs

Fixed16_16

A 16.16 fixed-point number.

Fixed2_14

A 2.14 fixed-point number.

Header

An SFNT file header.

Record

An SFNT file table record.

Sfnt

An SFNT file.

TableIter

An iterator over the tables in an SFNT file.

Tag

A four-byte tag.

Timestamp

A number of seconds that have elapsed since 1904-01-01T00:00:00Z.

Functions

checksum

Returns the SFNT checksum for the supplied bytes.