rustybuzz/hb/ot/layout/GSUB/
ligature_subst.rs1use 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
5impl 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(false, |set| set.would_apply(ctx))
12 }
13}
14
15impl Apply for LigatureSubstitution<'_> {
17 fn apply(&self, ctx: &mut hb_ot_apply_context_t) -> Option<()> {
18 let glyph = ctx.buffer.cur(0).as_glyph();
19 self.coverage
20 .get(glyph)
21 .and_then(|index| self.ligature_sets.get(index))
22 .and_then(|set| set.apply(ctx))
23 }
24}