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