[][src]Crate sfnt

A zero-allocation SFNT parser.

Example

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

use sfnt::{Sfnt};

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("head").unwrap();

    println!("{:?}", record);
    // Record { tag: "head", checksum: 4165466467, offset: 316, length: 54 }

    println!("{:?}", 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.

SfntIter

An iterator over the tables in an SFNT file.

Timestamp

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

Functions

checksum

Returns the SFNT checksum for the supplied bytes.