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::AlternateSubstitution; |
4 | |
5 | // AlternateSubstFormat1::would_apply |
6 | impl WouldApply for AlternateSubstitution<'_> { |
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 | // AlternateSubstFormat1::apply |
13 | impl Apply for AlternateSubstitution<'_> { |
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 set: AlternateSet<'_> = self.alternate_sets.get(index)?; |
18 | set.apply(ctx) |
19 | } |
20 | } |
21 | |