Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions lib/components/primitive-components/SilkscreenText.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,9 @@ export class SilkscreenText extends PrimitiveComponent<
subcircuit_id: subcircuit?.subcircuit_id ?? undefined,
pcb_group_id: this.getGroup()?.pcb_group_id ?? undefined,
is_knockout: props.isKnockout,
...(props.mirrored === undefined
? {}
: { is_mirrored: props.mirrored }),
knockout_padding: knockoutPadding,
})
this.pcb_silkscreen_text_ids.push(
Expand Down
1 change: 1 addition & 0 deletions lib/utils/createComponentsFromCircuitJson.ts
Original file line number Diff line number Diff line change
Expand Up @@ -586,6 +586,7 @@ export const createComponentsFromCircuitJson = (
)
} else {
const silkscreenText = new SilkscreenText({
mirrored: elm.is_mirrored,
anchorAlignment: elm.anchor_alignment || "center",
// Footprinter-generated reference text is a placeholder that should
// resolve to the component name. A literal from the explicit
Expand Down
1 change: 1 addition & 0 deletions lib/utils/createPinrowSilkscreenText.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export const createPinrowSilkscreenText = ({
pcbX: isNaN(elm.anchor_position.x) ? 0 : elm.anchor_position.x,
pcbY: elm.anchor_position.y,
pcbRotation: readableRotation ?? 0,
mirrored: elm.is_mirrored,
})
silkscreenText._footprinterFontSize = elm.font_size + 0.2
return silkscreenText
Expand Down
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -138,5 +138,8 @@
"@tscircuit/circuit-json-util": "^0.0.117",
"@tscircuit/props": "^0.0.672",
"circuit-json": "^0.0.507"
},
"patchedDependencies": {
"@tscircuit/props@0.0.672": "patches/@tscircuit%2Fprops@0.0.672.patch"
}
}
38 changes: 38 additions & 0 deletions patches/@tscircuit%2Fprops@0.0.672.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
--- a/dist/index.js
+++ b/dist/index.js
@@ -19228,6 +19228,8 @@
anchorAlignment: ninePointAnchor.default("center"),
font: z142.enum(["tscircuit2024"]).optional(),
fontSize: length9.optional(),
+ /** Explicit text mirroring, independent of layer. Omitted preserves the renderer default. */
+ mirrored: z142.boolean().optional(),
/**
* If true, text will knock out underlying silkscreen
*/
--- a/dist/index.d.ts
+++ b/dist/index.d.ts
@@ -239229,6 +239229,8 @@
anchorAlignment: z.ZodDefault<z.ZodEnum<["top_left", "top_center", "top_right", "center_left", "center", "center_right", "bottom_left", "bottom_center", "bottom_right"]>>;
font: z.ZodOptional<z.ZodEnum<["tscircuit2024"]>>;
fontSize: z.ZodOptional<z.ZodEffects<z.ZodUnion<[z.ZodString, z.ZodNumber]>, number, string | number>>;
+ /** Explicit text mirroring, independent of layer. Omitted preserves the renderer default. */
+ mirrored: z.ZodOptional<z.ZodBoolean>;
/**
* If true, text will knock out underlying silkscreen
*/
@@ -239285,6 +239287,7 @@
pcbSx?: PcbSx | undefined;
pcbRelative?: boolean | undefined;
relative?: boolean | undefined;
+ mirrored?: boolean | undefined;
isKnockout?: boolean | undefined;
knockoutPadding?: number | undefined;
knockoutPaddingLeft?: number | undefined;
@@ -239333,6 +239336,7 @@
pcbRelative?: boolean | undefined;
relative?: boolean | undefined;
anchorAlignment?: "top_left" | "top_center" | "top_right" | "center_left" | "center" | "center_right" | "bottom_left" | "bottom_center" | "bottom_right" | undefined;
+ mirrored?: boolean | undefined;
isKnockout?: boolean | undefined;
knockoutPadding?: string | number | undefined;
knockoutPaddingLeft?: string | number | undefined;
3 changes: 3 additions & 0 deletions patches/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
The props patch mirrors https://github.com/tscircuit/props/pull/885 and allows this PR's mirroring regression tests and type declarations to run against the currently published `@tscircuit/props@0.0.672`.

Before merging, replace the patch with a released props version containing that PR (update both the development dependency and the override). The patch is only used for local/CI development; consumers need the corresponding props release.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import { expect, test } from "bun:test"
import { getTestFixture } from "tests/fixtures/get-test-fixture"

test("silkscreen text preserves explicit mirroring through layer flips", () => {
const { circuit } = getTestFixture()
const mirrors = [true, false, undefined]
circuit.add(
<board width={60} height={25}>
{(["top", "bottom"] as const).flatMap((layer, row) =>
mirrors.map((mirrored, i) => (
<chip
key={`U${row}_${i}`}
name={`U${row}_${i}`}
layer={layer}
pcbX={-20 + i * 20}
pcbY={row ? -6 : 6}
footprint={
<footprint>
<silkscreentext
text={`ABC ${String(mirrored)}`}
mirrored={mirrored}
fontSize={1}
/>
</footprint>
}
/>
)),
)}
</board>,
)
circuit.render()
const texts = circuit.db.pcb_silkscreen_text
.list()
.filter((t) => t.text.startsWith("ABC"))
expect(texts).toHaveLength(6)
texts.forEach((text, i) => {
expect(text.is_mirrored).toBe(mirrors[i % 3])
if (mirrors[i % 3] === undefined)
expect(text).not.toHaveProperty("is_mirrored")
expect(text.layer).toBe(i < 3 ? "top" : "bottom")
})
expect(circuit).toMatchPcbSnapshot(import.meta.path)
})
Loading