Skip to main content

harfrust/hb/ot/gpos/
single.rs

1use crate::hb::ot_layout_gsubgpos::Apply;
2use crate::hb::ot_layout_gsubgpos::OT::hb_ot_apply_context_t;
3use read_fonts::tables::gpos::{SinglePosFormat1, SinglePosFormat2};
4
5impl Apply for SinglePosFormat1<'_> {
6    fn apply(&self, ctx: &mut hb_ot_apply_context_t) -> Option<()> {
7        let glyph = ctx.buffer.cur(0).as_glyph();
8        self.coverage().ok()?.get(glyph)?;
9        let format = self.value_format();
10        let offset = self.value_record_byte_range().start;
11        super::apply_value(ctx, ctx.buffer.idx, &self.offset_data(), offset, format);
12        ctx.buffer.idx += 1;
13        Some(())
14    }
15}
16
17impl Apply for SinglePosFormat2<'_> {
18    fn apply(&self, ctx: &mut hb_ot_apply_context_t) -> Option<()> {
19        let glyph = ctx.buffer.cur(0).as_glyph();
20        let index = self.coverage().ok()?.get(glyph)? as usize;
21        let format = self.value_format();
22        let offset = self.value_records_byte_range().start + (format.record_byte_len() * index);
23        super::apply_value(ctx, ctx.buffer.idx, &self.offset_data(), offset, format);
24        ctx.buffer.idx += 1;
25        Some(())
26    }
27}