rustybuzz/hb/ot/layout/GSUB/
multi_subst.rs

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::MultipleSubstitution;
4
5// MultipleSubstFormat1::would_apply
6impl WouldApply for MultipleSubstitution<'_> {
7    fn would_apply(&self, ctx: &WouldApplyContext) -> bool {
8        ctx.glyphs.len() == 1 && self.coverage.get(ctx.glyphs[0]).is_some()
9    }
10}
11
12// MultipleSubstFormat1::apply
13impl Apply for MultipleSubstitution<'_> {
14    fn apply(&self, ctx: &mut hb_ot_apply_context_t) -> Option<()> {
15        let glyph = ctx.buffer.cur(0).as_glyph();
16        let index = self.coverage.get(glyph)?;
17        let seq = self.sequences.get(index)?;
18        seq.apply(ctx)
19    }
20}