Skip to content
This repository was archived by the owner on Apr 7, 2026. It is now read-only.
This repository was archived by the owner on Apr 7, 2026. It is now read-only.

Relative placement anchor drifts if the drawn bounding box differs from its logically defined bounding box #188

@weiserhase

Description

@weiserhase

Description

When logic gates are placed relatively, their placement reference ccan differ from absolute placement causing visible horizontal drift in stacked layouts

This is a problem is also a problem for any component that expands the bounds by drawing outside of the predefined interface bounds.
Potentially any future component that adds one-sided protrusions in its draw geometry is subject to this problem.
Below are tests output that clearly show the layout shift.

test_currently.pdf
test_expected.pdf

Reproduction

Use two gates one with a inverter that is placed absolutely and one placed relative to the first one:

#import "@local/zap:0.5.0"

#zap.circuit({
  import zap: *

  let land = land.with(debug: true)

  land("a1", (0, 0), invert: true)
  land("a2", (rel: (0, -1.25), to: "a1"), invert: true)
})

Zap Version

Development

Typst Version

0.14.2 (default)

Additional Context

This issue occurs when a component’s drawn bounding box differs from its logically defined bounding box. Absolute placement uses the correct local coordinate system, but relative placement uses the cetz default anchor, which is set to the origin of the actual drawn content. Therefore, the cetz default anchor should be set to the local origin (0, 0).

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions