Skip to content

Commit

Permalink
Move to the latest released version of Skrifa instead of a git dep
Browse files Browse the repository at this point in the history
  • Loading branch information
rsheeter committed Jul 25, 2024
1 parent 557a5a2 commit 450c078
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 9 deletions.
6 changes: 4 additions & 2 deletions src/hb/face.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,13 +133,15 @@ impl<'a> hb_font_t<'a> {
}

pub(crate) fn get_nominal_glyph(&self, c: u32) -> Option<GlyphId> {
self.font.nominal_glyph(c).map(|gid| GlyphId(gid.to_u16()))
self.font
.nominal_glyph(c)
.map(|gid| GlyphId(gid.to_u32() as u16)) // TODO: remove as u16 when fully on read-fonts GlyphId
}

pub(crate) fn glyph_variation_index(&self, c: char, vs: char) -> Option<GlyphId> {
self.font
.nominal_variant_glyph(c as u32, vs as u32)
.map(|gid| GlyphId(gid.to_u16()))
.map(|gid| GlyphId(gid.to_u32() as u16)) // TODO: remove as u16 when fully on read-fonts GlyphId
}

pub(crate) fn glyph_h_advance(&self, glyph: GlyphId) -> i32 {
Expand Down
6 changes: 3 additions & 3 deletions src/hb/fonta/ot/gpos/pair.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ fn find_second_glyph<'a>(
while lo < hi {
let mid = (lo + hi) / 2;
let record_offset = set_offset + 2 + mid * record_size;
let glyph_id = base_data.read_at::<skrifa::GlyphId>(record_offset).ok()?;
let glyph_id = base_data.read_at::<skrifa::GlyphId16>(record_offset).ok()?;
if glyph_id < second_glyph {
lo = mid + 1
} else if glyph_id > second_glyph {
Expand All @@ -119,7 +119,7 @@ fn find_second_glyph<'a>(

impl Apply for PairPosFormat2<'_> {
fn apply(&self, ctx: &mut hb_ot_apply_context_t) -> Option<()> {
let first_glyph = ctx.buffer.cur(0).as_skrifa_glyph();
let first_glyph = ctx.buffer.cur(0).as_skrifa_glyph16();
self.coverage().ok()?.get(first_glyph)?;

let mut iter = skipping_iterator_t::new(ctx, ctx.buffer.idx, false);
Expand All @@ -132,7 +132,7 @@ impl Apply for PairPosFormat2<'_> {
}

let second_glyph_index = iter.index();
let second_glyph = ctx.buffer.info[second_glyph_index].as_skrifa_glyph();
let second_glyph = ctx.buffer.info[second_glyph_index].as_skrifa_glyph16();

let finish = |ctx: &mut hb_ot_apply_context_t, iter_index: &mut usize, has_record2| {
if has_record2 {
Expand Down
4 changes: 2 additions & 2 deletions src/hb/fonta/ot/gsub/multiple.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ impl WouldApply for MultipleSubstFormat1<'_> {

impl Apply for MultipleSubstFormat1<'_> {
fn apply(&self, ctx: &mut hb_ot_apply_context_t) -> Option<()> {
let glyph = ctx.buffer.cur(0).as_glyph().0;
let index = self.coverage().ok()?.get(skrifa::GlyphId::new(glyph))? as usize;
let gid = ctx.buffer.cur(0).as_skrifa_glyph16();
let index = self.coverage().ok()?.get(gid)? as usize;
let substs = self.sequences().get(index).ok()?.substitute_glyph_ids();
match substs.len() {
// Spec disallows this, but Uniscribe allows it.
Expand Down
5 changes: 3 additions & 2 deletions src/hb/fonta/ot/gsub/single.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,18 @@ use ttf_parser::GlyphId;

impl WouldApply for SingleSubstFormat1<'_> {
fn would_apply(&self, ctx: &WouldApplyContext) -> bool {
let gid = skrifa::GlyphId::from(ctx.glyphs[0].0);
ctx.glyphs.len() == 1
&& self
.coverage()
.map(|cov| cov.get(ctx.glyphs[0].0.into()).is_some())
.map(|cov| cov.get(gid).is_some())
.unwrap_or_default()
}
}

impl Apply for SingleSubstFormat1<'_> {
fn apply(&self, ctx: &mut hb_ot_apply_context_t) -> Option<()> {
let glyph = ctx.buffer.cur(0).as_skrifa_glyph();
let glyph = ctx.buffer.cur(0).as_skrifa_glyph16();
self.coverage().ok()?.get(glyph)?;
let subst = (glyph.to_u16() as i32 + self.delta_glyph_id() as i32) as u16;
ctx.replace_glyph(GlyphId(subst));
Expand Down

0 comments on commit 450c078

Please sign in to comment.