1use crate::hb::ot_layout_gsubgpos::OT::hb_ot_apply_context_t;
2use crate::hb::ot_layout_gsubgpos::{Apply, WouldApply, WouldApplyContext};
3use ttf_parser::gsub::LigatureSubstitution;
4
5// LigatureSubstFormat1::would_apply
6impl WouldApply for LigatureSubstitution<'_> {
7 fn would_apply(&self, ctx: &WouldApplyContext) -> bool {
8 self.coverage
9 .get(ctx.glyphs[0])
10 .and_then(|index| self.ligature_sets.get(index))
11 .map_or(default:false, |set: LazyOffsetArray16<'_, Ligature<'_>>| set.would_apply(ctx))
12 }
13}
14
15// LigatureSubstFormat1::apply
16impl Apply for LigatureSubstitution<'_> {
17 fn apply(&self, ctx: &mut hb_ot_apply_context_t) -> Option<()> {
18 let glyph: GlyphId = ctx.buffer.cur(0).as_glyph();
19 self.coverage
20 .get(glyph)
21 .and_then(|index: u16| self.ligature_sets.get(index))
22 .and_then(|set: LazyOffsetArray16<'_, Ligature<'_>>| set.apply(ctx))
23 }
24}
25