| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
pub static FACE: &[u8] = include_bytes!(env!("SHOP_FONT_FACE")); |
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
pub static LICENSE: &str = include_str!(env!("SHOP_FONT_LICENSE")); |
| 17 |
|
| 18 |
|
| 19 |
pub const FAMILY: &str = env!("SHOP_FONT_FAMILY"); |
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
pub const DEFAULT_STYLE: &str = env!("SHOP_FONT_STYLE"); |
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
pub const DEFAULT_WEIGHT: f32 = { |
| 30 |
|
| 31 |
|
| 32 |
match env!("SHOP_FONT_DEFAULT_WEIGHT").as_bytes() { |
| 33 |
[b'2', b'0', b'0', ..] => 200.0, |
| 34 |
[b'4', b'0', b'0', ..] => 400.0, |
| 35 |
_ => f32::NAN, |
| 36 |
} |
| 37 |
}; |
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
pub const WEIGHT: f32 = 400.0; |
| 44 |
|
| 45 |
#[cfg(test)] |
| 46 |
mod tests { |
| 47 |
use super::*; |
| 48 |
|
| 49 |
#[test] |
| 50 |
fn the_face_is_a_truetype_file_carrying_an_axis() { |
| 51 |
assert_eq!(&FACE[0..4], &[0x00, 0x01, 0x00, 0x00], "not an sfnt"); |
| 52 |
let tags: Vec<&[u8]> = (0..u16::from_be_bytes([FACE[4], FACE[5]]) as usize) |
| 53 |
.map(|i| &FACE[12 + 16 * i..16 + 16 * i]) |
| 54 |
.collect(); |
| 55 |
for wanted in [b"fvar", b"gvar", b"cmap", b"glyf"] { |
| 56 |
assert!( |
| 57 |
tags.contains(&&wanted[..]), |
| 58 |
"{} is missing, so this is not a cut variable face", |
| 59 |
String::from_utf8_lossy(wanted) |
| 60 |
); |
| 61 |
} |
| 62 |
} |
| 63 |
|
| 64 |
#[test] |
| 65 |
fn the_licence_travels_with_it() { |
| 66 |
assert!(LICENSE.contains("SIL OPEN FONT LICENSE")); |
| 67 |
} |
| 68 |
|
| 69 |
|
| 70 |
#[test] |
| 71 |
fn the_faces_own_default_is_not_the_weight_we_draw_at() { |
| 72 |
assert_eq!(DEFAULT_STYLE, "ExtraLight"); |
| 73 |
assert!( |
| 74 |
(WEIGHT - DEFAULT_WEIGHT).abs() > f32::EPSILON, |
| 75 |
"the weight shop draws at is the file's own default, so naming it bought nothing" |
| 76 |
); |
| 77 |
} |
| 78 |
} |
| 79 |
|