Skip to content

Commit 0dd7b14

Browse files
dfrgbehdad
andauthored
Fix off by one in would apply for chain context format 3 (#278)
* Fix off by one in would apply for chain context format 3 Also use the proper consonant check in the Indic shaper. * Add test --------- Co-authored-by: Behdad Esfahbod <[email protected]>
1 parent dee1300 commit 0dd7b14

File tree

4 files changed

+23
-19
lines changed

4 files changed

+23
-19
lines changed

src/hb/ot/contextual.rs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -413,12 +413,16 @@ impl WouldApply for ChainedSequenceContextFormat3<'_> {
413413
(!ctx.zero_context
414414
|| (self.backtrack_coverage_offsets().is_empty()
415415
&& self.lookahead_coverage_offsets().is_empty()))
416-
&& (ctx.glyphs.len() == input_coverages.len() + 1
417-
&& input_coverages.iter().enumerate().all(|(i, coverage)| {
418-
coverage
419-
.map(|cov| cov.get(ctx.glyphs[i + 1]).is_some())
420-
.unwrap_or(false)
421-
}))
416+
&& (ctx.glyphs.len() == input_coverages.len()
417+
&& input_coverages
418+
.iter()
419+
.skip(1)
420+
.enumerate()
421+
.all(|(i, coverage)| {
422+
coverage
423+
.map(|cov| cov.get(ctx.glyphs[i + 1]).is_some())
424+
.unwrap_or(false)
425+
}))
422426
}
423427
}
424428

src/hb/ot_shaper_indic.rs

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,6 @@ impl GlyphInfo {
6969
self.is_one_of(CONSONANT_FLAGS_INDIC)
7070
}
7171

72-
pub(crate) fn is_consonant_myanmar(&self) -> bool {
73-
self.is_one_of(CONSONANT_FLAGS_MYANMAR)
74-
}
75-
7672
fn is_halant(&self) -> bool {
7773
self.is_one_of(rb_flag(ot_category_t::OT_H as u32))
7874
}
@@ -267,14 +263,6 @@ const CONSONANT_FLAGS_INDIC: u32 = category_flag(ot_category_t::OT_C)
267263
| category_flag(ot_category_t::OT_PLACEHOLDER)
268264
| category_flag(ot_category_t::OT_DOTTEDCIRCLE);
269265

270-
const CONSONANT_FLAGS_MYANMAR: u32 = category_flag(ot_category_t::OT_C)
271-
| category_flag(ot_category_t::OT_CS)
272-
| category_flag(ot_category_t::OT_Ra)
273-
// | category_flag(ot_category_t::OT_CM)
274-
| category_flag(ot_category_t::IV)
275-
| category_flag(ot_category_t::OT_GB)
276-
| category_flag(ot_category_t::OT_DOTTEDCIRCLE);
277-
278266
const JOINER_FLAGS: u32 =
279267
category_flag(ot_category_t::OT_ZWJ) | category_flag(ot_category_t::OT_ZWNJ);
280268

@@ -890,7 +878,7 @@ fn initial_reordering_consonant_syllable(
890878
loop {
891879
i -= 1;
892880
// -> until a consonant is found
893-
if buffer.info[i].is_consonant_myanmar() {
881+
if buffer.info[i].is_consonant() {
894882
// -> that does not have a below-base or post-base form
895883
// (post-base forms have to follow below-base forms),
896884
if buffer.info[i].indic_position() != ot_position_t::POS_BELOW_C
592 Bytes
Binary file not shown.

tests/shaping/in_house.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48547,6 +48547,18 @@ fn indic_malayalam_dot_reph_015() {
4854748547
);
4854848548
}
4854948549

48550+
#[test]
48551+
fn indic_misc_002() {
48552+
assert_eq!(
48553+
shape(
48554+
"tests/fonts/in-house/755160ddba002332349fda3eb999e629d63dccf6.ttf",
48555+
"\u{0A2D}\u{0A4D}\u{0A30}\u{0A42}",
48556+
"",
48557+
),
48558+
"[gid1=0+594|gid5=0+0|gid3=0+0]"
48559+
);
48560+
}
48561+
4855048562
#[test]
4855148563
fn indic_old_spec_001() {
4855248564
assert_eq!(

0 commit comments

Comments
 (0)