diff --git a/masque/library.py b/masque/library.py index 13b4d26..9d1f1b7 100644 --- a/masque/library.py +++ b/masque/library.py @@ -1106,7 +1106,7 @@ class ILibrary(ILibraryView, MutableMapping[str, 'Pattern'], metaclass=ABCMeta): for ii, values in shape_entries: offset, scale, rotation, mirror_x = values pat.ref(target=target, offset=offset, scale=scale, - rotation=rotation, mirrored=(mirror_x, False)) + rotation=rotation, mirrored=mirror_x) shapes_to_remove.append(ii) # Remove any shapes for which we have created refs. diff --git a/masque/test/test_library.py b/masque/test/test_library.py index 335b6ec..09c258b 100644 --- a/masque/test/test_library.py +++ b/masque/test/test_library.py @@ -6,7 +6,7 @@ from ..pattern import Pattern from ..error import LibraryError, PatternError from ..ports import Port from ..repetition import Grid -from ..shapes import Path +from ..shapes import Arc, Ellipse, Path, Text from ..file.utils import preflight if TYPE_CHECKING: @@ -261,6 +261,29 @@ def test_library_dedup_shapes_does_not_merge_custom_capped_paths() -> None: assert len(lib["top"].shapes[(1, 0)]) == 2 +def test_library_dedup_text_preserves_scale_and_mirror_flag() -> None: + lib = Library() + pat = Pattern() + pat.shapes[(1, 0)] += [ + Text("A", 10, "dummy.ttf", offset=(0, 0)), + Text("A", 10, "dummy.ttf", offset=(100, 0)), + ] + lib["top"] = pat + + lib.dedup(exclude_types=(), norm_value=5, threshold=2) + + target_name = next(iter(lib["top"].refs)) + refs = lib["top"].refs[target_name] + assert [ref.mirrored for ref in refs] == [False, False] + assert [ref.scale for ref in refs] == [2.0, 2.0] + assert cast("Text", lib[target_name].shapes[(1, 0)][0]).height == 5 + + flat = lib.flatten("top")["top"] + assert [cast("Text", shape).height for shape in flat.shapes[(1, 0)]] == [10, 10] + + + + def test_library_dedup_handles_multiple_duplicate_groups() -> None: from ..shapes import Circle