From b8aff9214e397e8f8652053e11e0f4773918abcf Mon Sep 17 00:00:00 2001 From: Cosimo Lupo Date: Wed, 31 Jul 2024 18:59:02 +0100 Subject: [PATCH 1/2] propagate_anchors: fix mis-named test case, add specific one for *origin anchors --- glyphs-reader/src/propagate_anchors.rs | 44 +++++++++++++++++++++----- 1 file changed, 36 insertions(+), 8 deletions(-) diff --git a/glyphs-reader/src/propagate_anchors.rs b/glyphs-reader/src/propagate_anchors.rs index e556fb29..e8725da3 100644 --- a/glyphs-reader/src/propagate_anchors.rs +++ b/glyphs-reader/src/propagate_anchors.rs @@ -797,16 +797,9 @@ mod tests { } #[test] - fn origin_anchor() { + fn component_anchor() { // derived from the observed behaviour of glyphs 3.2.2 (3259) let mut glyphs = GlyphSetBuilder::new() - .add_glyph("a", |glyph| { - glyph - .add_anchor("*origin", (-20, 0)) - .add_anchor("bottom", (242, 7)) - .add_anchor("ogonek", (402, 9)) - .add_anchor("top", (246, 548)); - }) .add_glyph("acutecomb", |glyph| { glyph .add_anchor("_top", (150, 580)) @@ -847,6 +840,41 @@ mod tests { ); } + #[test] + fn origin_anchor() { + // derived from the observed behaviour of glyphs 3.2.2 (3259) + let mut glyphs = GlyphSetBuilder::new() + .add_glyph("a", |glyph| { + glyph + .add_anchor("*origin", (-20, 0)) + .add_anchor("bottom", (242, 7)) + .add_anchor("ogonek", (402, 9)) + .add_anchor("top", (246, 548)); + }) + .add_glyph("acutecomb", |glyph| { + glyph + .add_anchor("_top", (150, 580)) + .add_anchor("top", (170, 792)); + }) + .add_glyph("aacute", |glyph| { + glyph + .add_component("a", (0, 0)) + .add_component("acutecomb", (96, -32)); + }) + .build(); + propagate_all_anchors_impl(&mut glyphs); + + let new_glyph = glyphs.get("aacute").unwrap(); + assert_eq!( + new_glyph.layers[0].anchors, + [ + ("bottom", (262.0, 7.0)), + ("ogonek", (422.0, 9.0)), + ("top", (286.0, 760.0)), + ] + ); + } + #[test] fn invert_names_on_rotation() { // derived from the observed behaviour of glyphs 3.2.2 (3259) From ecc727dd17d5623bf18d25a4315c1b0199fd1779 Mon Sep 17 00:00:00 2001 From: Cosimo Lupo Date: Thu, 1 Aug 2024 10:47:27 +0100 Subject: [PATCH 2/2] fix origin_anchor test, sync with values in PropagateAnchorsTest.glyphs the inputs to the origin_anchor test are now the same as in the PropagateAnchorsTest.glyphs file and the expected results now match the observed behavior when running the built-in anchorsTraversingComponents method from within Glyphs.app macro panel. --- glyphs-reader/src/propagate_anchors.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/glyphs-reader/src/propagate_anchors.rs b/glyphs-reader/src/propagate_anchors.rs index e8725da3..67f24883 100644 --- a/glyphs-reader/src/propagate_anchors.rs +++ b/glyphs-reader/src/propagate_anchors.rs @@ -859,7 +859,7 @@ mod tests { .add_glyph("aacute", |glyph| { glyph .add_component("a", (0, 0)) - .add_component("acutecomb", (96, -32)); + .add_component("acutecomb", (116, -32)); }) .build(); propagate_all_anchors_impl(&mut glyphs);