[ILibrary] fix dedup messing up rotations
This commit is contained in:
parent
46a3559391
commit
620b001af5
2 changed files with 25 additions and 2 deletions
|
|
@ -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
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue