diff options
| author | Laurenz <laurmaedje@gmail.com> | 2019-06-25 21:07:06 +0200 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2019-06-25 21:07:06 +0200 |
| commit | 7eec0b8dd70446803c9ffb84a253ebb7e68f3567 (patch) | |
| tree | 1c1948b70e6ed2fcd03ac44aa3e08353de9d0fd8 /src/font/mod.rs | |
| parent | 030d301f0c98b4d19a3f8ae22f553e22f74d592f (diff) | |
Add more tests for table parsers 🔋
Diffstat (limited to 'src/font/mod.rs')
| -rw-r--r-- | src/font/mod.rs | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/src/font/mod.rs b/src/font/mod.rs index 9c928938..5d257a9a 100644 --- a/src/font/mod.rs +++ b/src/font/mod.rs @@ -83,14 +83,15 @@ impl Font { // Create a conversion function between font units and sizes. let font_unit_ratio = 1.0 / (head.units_per_em as f32); - let font_unit_to_size = |x| Size::pt(font_unit_ratio * x as f32); + let font_unit_to_size = |x| Size::pt(font_unit_ratio * x); // Find out the name of the font. let font_name = name.get_decoded(NameEntry::PostScriptName) .unwrap_or_else(|| "unknown".to_owned()); // Convert the widths from font units to sizes. - let widths = hmtx.metrics.iter().map(|m| font_unit_to_size(m.advance_width)).collect(); + let widths = hmtx.metrics.iter() + .map(|m| font_unit_to_size(m.advance_width as f32)).collect(); // Calculate the typesetting-relevant metrics. let metrics = FontMetrics { @@ -98,14 +99,14 @@ impl Font { monospace: post.is_fixed_pitch, italic_angle: post.italic_angle.to_f32(), bounding_box: [ - font_unit_to_size(head.x_min), - font_unit_to_size(head.y_min), - font_unit_to_size(head.x_max), - font_unit_to_size(head.y_max), + font_unit_to_size(head.x_min as f32), + font_unit_to_size(head.y_min as f32), + font_unit_to_size(head.x_max as f32), + font_unit_to_size(head.y_max as f32), ], - ascender: font_unit_to_size(os2.s_typo_ascender), - descender: font_unit_to_size(os2.s_typo_descender), - cap_height: font_unit_to_size(os2.s_cap_height.unwrap_or(os2.s_typo_ascender)), + ascender: font_unit_to_size(os2.s_typo_ascender as f32), + descender: font_unit_to_size(os2.s_typo_descender as f32), + cap_height: font_unit_to_size(os2.s_cap_height.unwrap_or(os2.s_typo_ascender) as f32), weight_class: os2.us_weight_class, }; @@ -352,7 +353,6 @@ error_type! { OpentypeError::InvalidFont(message) => FontError::InvalidFont(message), OpentypeError::MissingTable(tag) => FontError::MissingTable(tag.to_string()), OpentypeError::Io(err) => FontError::Io(err), - _ => panic!("unexpected extensible variant"), }), } |
