Skip to content

Commit

Permalink
Add base marks to mark filtering sets of mark-to-mark attachment lookups
Browse files Browse the repository at this point in the history
Otherwise the lookups will not be applied as the base marks will be
skipped.

Fixes #958
  • Loading branch information
khaledhosny committed Sep 11, 2024
1 parent 4c06579 commit 40bae14
Show file tree
Hide file tree
Showing 3 changed files with 132 additions and 6 deletions.
5 changes: 5 additions & 0 deletions fontbe/src/features/marks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,11 @@ impl MarkGroup<'_> {
self.marks
.iter()
.map(|(name, _)| glyph_order.glyph_id(name).unwrap())
.chain(
self.bases
.iter()
.map(|(name, _)| glyph_order.glyph_id(name).unwrap()),
)
.collect()
})
}
Expand Down
52 changes: 46 additions & 6 deletions fontc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -608,6 +608,7 @@ mod tests {
},
TableRef,
},
tables::layout::LookupFlag,
types::NameId,
};

Expand Down Expand Up @@ -2656,10 +2657,12 @@ mod tests {
let result = TestCompile::compile_source("glyphs3/Oswald-AE-comb.glyphs");
let font = result.font();
let gpos = font.gpos().unwrap();
let gdef = font.gdef().unwrap();
let acutecomb = result.get_gid("acutecomb");
let brevecomb = result.get_gid("brevecomb");
let tildecomb = result.get_gid("tildecomb");
let macroncomb = result.get_gid("macroncomb");
let breveinvertedcomb = result.get_gid("breveinvertedcomb");

let mark_mark_lookups = gpos
.lookup_list()
Expand All @@ -2670,14 +2673,20 @@ mod tests {
Ok(PositionLookup::MarkToMark(lookup)) => Some(lookup),
_ => None,
})
.flat_map(|lookup| lookup.subtables().iter())
.collect::<Result<Vec<_>, _>>()
.unwrap();
assert_eq!(mark_mark_lookups.len(), 1);
.collect::<Vec<_>>();
assert_eq!(mark_mark_lookups.len(), 2);

let mark_mark_lookup = mark_mark_lookups.first().unwrap();
let mark_mark_subtables = mark_mark_lookup
.subtables()
.iter()
.map(|s| s.unwrap())
.collect::<Vec<_>>();
assert_eq!(mark_mark_subtables.len(), 1);

let mut bases = Vec::new();
let mut marks = Vec::new();
for sub in &mark_mark_lookups {
for sub in &mark_mark_subtables {
let mark_cov = sub.mark1_coverage().unwrap();
let base_cov = sub.mark2_coverage().unwrap();
let mark1array = sub.mark1_array().unwrap();
Expand Down Expand Up @@ -2727,7 +2736,38 @@ mod tests {
(acutecomb, vec![(0, 810)]),
(brevecomb, vec![(-1, 776)]),
(tildecomb, vec![(0, 776)]),
(macroncomb, vec![(0, 810)])
(macroncomb, vec![(0, 810)]),
(breveinvertedcomb, vec![(-1, 776)]),
]
);

let mark_filter_id = mark_mark_lookup
.lookup_flag()
.contains(LookupFlag::USE_MARK_FILTERING_SET)
.then_some(mark_mark_lookup.mark_filtering_set())
.flatten();
assert_eq!(mark_filter_id, Some(0));

let mark_filter_set = gdef
.mark_glyph_sets_def()
.unwrap()
.as_ref()
.map(|sets| {
sets.coverages()
.get(mark_filter_id.unwrap().into())
.unwrap()
})
.map(|cov| cov.iter().collect::<Vec<_>>())
.unwrap();

assert_eq!(
mark_filter_set,
vec![
acutecomb,
brevecomb,
tildecomb,
macroncomb,
breveinvertedcomb
]
);
}
Expand Down
81 changes: 81 additions & 0 deletions resources/testdata/glyphs3/Oswald-AE-comb.glyphs
Original file line number Diff line number Diff line change
Expand Up @@ -1735,6 +1735,87 @@ width = 278;
};
};
};
},
{
glyphname = breveinvertedcomb;
layers = (
{
anchors = (
{
name = _top.a;
pos = (0,578);
},
{
name = top;
pos = (0,810);
},
{
name = top.a;
pos = (0,810);
}
);
layerId = "FCD7E481-103E-4A6C-AD70-01DA443B2AD0";
shapes = (
{
pos = (0,1389);
ref = brevecomb;
scale = (1,-1);
}
);
width = 100;
},
{
anchors = (
{
name = _top.a;
pos = (0,578);
},
{
name = top;
pos = (-1,776);
},
{
name = top.a;
pos = (0,776);
}
);
layerId = "8AC5A1D3-32A8-4416-86FC-94176A419B8F";
shapes = (
{
pos = (0,1417);
ref = brevecomb;
scale = (1,-1);
}
);
width = 0;
},
{
anchors = (
{
name = _top.a;
pos = (0,578);
},
{
name = top;
pos = (0,802);
},
{
name = top.a;
pos = (0,802);
}
);
layerId = "F66B25F0-8957-42F3-9BF7-6C5DDCB0258B";
shapes = (
{
pos = (0,1442);
ref = brevecomb;
scale = (1,-1);
}
);
width = 0;
}
);
unicode = 785;
}
);
instances = (
Expand Down

0 comments on commit 40bae14

Please sign in to comment.