| 1 |
use std::num::NonZeroU16; |
| 2 |
use ttf_parser::maxp::Table; |
| 3 |
use crate::{convert, Unit::*}; |
| 4 |
|
| 5 |
#[test] |
| 6 |
fn version_05() { |
| 7 |
let table = Table::parse(&convert(&[ |
| 8 |
Fixed(0.3125), // version |
| 9 |
UInt16(1), // number of glyphs |
| 10 |
])).unwrap(); |
| 11 |
assert_eq!(table.number_of_glyphs, NonZeroU16::new(1).unwrap()); |
| 12 |
} |
| 13 |
|
| 14 |
#[test] |
| 15 |
fn version_1_full() { |
| 16 |
let table = Table::parse(&convert(&[ |
| 17 |
Fixed(1.0), // version |
| 18 |
UInt16(1), // number of glyphs |
| 19 |
UInt16(0), // maximum points in a non-composite glyph |
| 20 |
UInt16(0), // maximum contours in a non-composite glyph |
| 21 |
UInt16(0), // maximum points in a composite glyph |
| 22 |
UInt16(0), // maximum contours in a composite glyph |
| 23 |
UInt16(0), // maximum zones |
| 24 |
UInt16(0), // maximum twilight points |
| 25 |
UInt16(0), // number of Storage Area locations |
| 26 |
UInt16(0), // number of FDEFs |
| 27 |
UInt16(0), // number of IDEFs |
| 28 |
UInt16(0), // maximum stack depth |
| 29 |
UInt16(0), // maximum byte count for glyph instructions |
| 30 |
UInt16(0), // maximum number of components |
| 31 |
UInt16(0), // maximum levels of recursion |
| 32 |
])).unwrap(); |
| 33 |
assert_eq!(table.number_of_glyphs, NonZeroU16::new(1).unwrap()); |
| 34 |
} |
| 35 |
|
| 36 |
#[test] |
| 37 |
fn version_1_trimmed() { |
| 38 |
// We don't really care about the data after the number of glyphs. |
| 39 |
let table = Table::parse(&convert(&[ |
| 40 |
Fixed(1.0), // version |
| 41 |
UInt16(1), // number of glyphs |
| 42 |
])).unwrap(); |
| 43 |
assert_eq!(table.number_of_glyphs, NonZeroU16::new(1).unwrap()); |
| 44 |
} |
| 45 |
|
| 46 |
#[test] |
| 47 |
fn unknown_version() { |
| 48 |
let table = Table::parse(&convert(&[ |
| 49 |
Fixed(0.0), // version |
| 50 |
UInt16(1), // number of glyphs |
| 51 |
])); |
| 52 |
assert!(table.is_none()); |
| 53 |
} |
| 54 |
|
| 55 |
#[test] |
| 56 |
fn zero_glyphs() { |
| 57 |
let table = Table::parse(&convert(&[ |
| 58 |
Fixed(0.3125), // version |
| 59 |
UInt16(0), // number of glyphs |
| 60 |
])); |
| 61 |
assert!(table.is_none()); |
| 62 |
} |
| 63 |
|
| 64 |
// TODO: what to do when the number of glyphs is 0xFFFF? |
| 65 |
// we're actually checking this in loca |