Skip to content

Commit

Permalink
Revert "Update ttf-parser to 0.13 (#45)" (#47)
Browse files Browse the repository at this point in the history
This reverts commit 72c4373.
  • Loading branch information
alexheretic authored Oct 28, 2021
1 parent 8006dd0 commit 3f0f9e7
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 15 deletions.
2 changes: 1 addition & 1 deletion glyph/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
2 changes: 1 addition & 1 deletion glyph/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
18 changes: 5 additions & 13 deletions glyph/src/ttfp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,8 +185,7 @@ macro_rules! impl_font {
impl Font for $font {
#[inline]
fn units_per_em(&self) -> Option<f32> {
// 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]
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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));
}
Expand Down

0 comments on commit 3f0f9e7

Please sign in to comment.