1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
//! Font toolbox.
//!
//! # Example
//!
//! ```
//! extern crate font;
//!
//! use font::{File, Segment};
//!
//! # fn main() {
//! let path = "SourceSerifPro-Regular.otf";
//! # let path = "tests/fixtures/SourceSerifPro-Regular.otf";
//! let File { fonts, .. } = File::open(path).unwrap();
//! let glyph = fonts[0].draw('&').unwrap().unwrap();
//!
//! for contour in glyph.iter() {
//!     for segment in contour.iter() {
//!         match segment {
//!             &Segment::Linear(..) => { /* … */ },
//!             &Segment::Quadratic(..) => { /* … */ },
//!             &Segment::Cubic(..) => { /* … */ },
//!         }
//!     }
//! }
//! # }
//! ```

extern crate opentype;
extern crate postscript;
extern crate truetype;

/// An error.
pub type Error = std::io::Error;

/// A number.
pub type Number = f32;

/// A result.
pub type Result<T> = std::io::Result<T>;

macro_rules! deref {
    ($struct_name:ident::$field_name:ident => $target_name:ty) => (
        impl ::std::ops::Deref for $struct_name {
            type Target = $target_name;

            #[inline]
            fn deref(&self) -> &Self::Target {
                &self.$field_name
            }
        }

        impl ::std::ops::DerefMut for $struct_name {
            #[inline]
            fn deref_mut(&mut self) -> &mut Self::Target {
                &mut self.$field_name
            }
        }
    );
}

macro_rules! raise(
    ($message:expr) => (return Err(::Error::new(::std::io::ErrorKind::Other, $message)));
);

macro_rules! some(
    ($option:expr, $message:expr) => (
        match $option {
            Some(value) => value,
            _ => raise!($message),
        }
    );
);

mod builder;
mod case;
mod file;
mod font;
mod format;
mod glyph;
mod offset;

pub use case::Case;
pub use file::File;
pub use font::Font;
pub use glyph::{Contour, Glyph, Segment};
pub use offset::Offset;