From 3f0f9e7e710c1238f6ae0802018260cc932c0d62 Mon Sep 17 00:00:00 2001 From: Alex Butler Date: Fri, 29 Oct 2021 00:42:48 +0100 Subject: [PATCH] Revert "Update ttf-parser to 0.13 (#45)" (#47) This reverts commit 72c437378ac10b22fae0f7789f92493713536a05. --- glyph/CHANGELOG.md | 2 +- glyph/Cargo.toml | 2 +- glyph/src/ttfp.rs | 18 +++++------------- 3 files changed, 7 insertions(+), 15 deletions(-) diff --git a/glyph/CHANGELOG.md b/glyph/CHANGELOG.md index e884373..1ba9465 100644 --- a/glyph/CHANGELOG.md +++ b/glyph/CHANGELOG.md @@ -1,5 +1,5 @@ # Unreleased -* Update _ttf-parser_ to `0.13.1`. +* Update _owned_ttf_parser_ to `0.12.1` to ensure consistent glyph bounding box behaviour. # 0.2.11 * `Font::outline` will return `None` for rare invalid/empty glyph bounds instead of panicking. diff --git a/glyph/Cargo.toml b/glyph/Cargo.toml index b11854f..a244672 100644 --- a/glyph/Cargo.toml +++ b/glyph/Cargo.toml @@ -10,7 +10,7 @@ license = "Apache-2.0" readme="README.md" [dependencies] -owned_ttf_parser = { version = "0.13.1", default-features = false } +owned_ttf_parser = { version = "0.12.1", default-features = false } ab_glyph_rasterizer = { version = "0.1.2", path = "../rasterizer", default-features = false } # no_std float stuff # renamed to enable a "libm" feature diff --git a/glyph/src/ttfp.rs b/glyph/src/ttfp.rs index fc907e9..ba5177d 100644 --- a/glyph/src/ttfp.rs +++ b/glyph/src/ttfp.rs @@ -185,8 +185,7 @@ macro_rules! impl_font { impl Font for $font { #[inline] fn units_per_em(&self) -> Option { - // TODO unwrap signature when making next breaking change - Some(self.0.as_face_ref().units_per_em().into()) + self.0.as_face_ref().units_per_em().map(f32::from) } #[inline] @@ -255,11 +254,8 @@ macro_rules! impl_font { fn kern_unscaled(&self, first: GlyphId, second: GlyphId) -> f32 { self.0 .as_face_ref() - .tables() - .kern - .iter() - .flat_map(|c| c.subtables) - .filter(|st| st.horizontal && !st.variable) + .kerning_subtables() + .filter(|st| st.is_horizontal() && !st.is_variable()) .find_map(|st| st.glyphs_kerning(first.into(), second.into())) .map(f32::from) .unwrap_or_default() @@ -306,17 +302,13 @@ macro_rules! impl_font { let inner = Box::new( face_ref - .tables() - .cmap - .iter() - .flat_map(|c| c.subtables) + .character_mapping_subtables() .filter(|s| s.is_unicode()) .flat_map(move |subtable| { let mut pairs = Vec::new(); subtable.codepoints(|c| { if let Ok(ch) = char::try_from(c) { - if let Some(idx) = subtable.glyph_index(ch).filter(|i| i.0 > 0) - { + if let Some(idx) = subtable.glyph_index(c).filter(|i| i.0 > 0) { if used_indices.insert(idx.0) { pairs.push((GlyphId(idx.0), ch)); }