circuit-to-svg 0.0.160 → 0.0.162
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +48 -21
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -637,6 +637,33 @@ function createSvgObjectsFromPcbSilkscreenText(pcbSilkscreenText, ctx) {
|
|
|
637
637
|
...layer === "bottom" ? [scale(-1, 1)] : []
|
|
638
638
|
);
|
|
639
639
|
const color = layer === "bottom" ? colorMap2.silkscreen.bottom : colorMap2.silkscreen.top;
|
|
640
|
+
const lines = text.split("\n");
|
|
641
|
+
const children = lines.length === 1 ? [
|
|
642
|
+
{
|
|
643
|
+
type: "text",
|
|
644
|
+
value: text,
|
|
645
|
+
name: "",
|
|
646
|
+
attributes: {},
|
|
647
|
+
children: []
|
|
648
|
+
}
|
|
649
|
+
] : lines.map((line, idx) => ({
|
|
650
|
+
type: "element",
|
|
651
|
+
name: "tspan",
|
|
652
|
+
value: "",
|
|
653
|
+
attributes: {
|
|
654
|
+
x: "0",
|
|
655
|
+
...idx > 0 ? { dy: transformedFontSize.toString() } : {}
|
|
656
|
+
},
|
|
657
|
+
children: [
|
|
658
|
+
{
|
|
659
|
+
type: "text",
|
|
660
|
+
value: line,
|
|
661
|
+
name: "",
|
|
662
|
+
attributes: {},
|
|
663
|
+
children: []
|
|
664
|
+
}
|
|
665
|
+
]
|
|
666
|
+
}));
|
|
640
667
|
const svgObject = {
|
|
641
668
|
name: "text",
|
|
642
669
|
type: "element",
|
|
@@ -655,15 +682,7 @@ function createSvgObjectsFromPcbSilkscreenText(pcbSilkscreenText, ctx) {
|
|
|
655
682
|
"data-pcb-silkscreen-text-id": pcbSilkscreenText.pcb_component_id,
|
|
656
683
|
stroke: "none"
|
|
657
684
|
},
|
|
658
|
-
children
|
|
659
|
-
{
|
|
660
|
-
type: "text",
|
|
661
|
-
value: text,
|
|
662
|
-
name: "",
|
|
663
|
-
attributes: {},
|
|
664
|
-
children: []
|
|
665
|
-
}
|
|
666
|
-
],
|
|
685
|
+
children,
|
|
667
686
|
value: ""
|
|
668
687
|
};
|
|
669
688
|
return [svgObject];
|
|
@@ -4025,6 +4044,8 @@ var createSvgObjectsForSchPortPinLabel = (params) => {
|
|
|
4025
4044
|
const screenPinNumberTextPos = applyToPoint29(transform, realPinNumberPos);
|
|
4026
4045
|
const label = schPort.display_pin_label ?? schComponent.port_labels?.[`${schPort.pin_number}`];
|
|
4027
4046
|
if (!label) return [];
|
|
4047
|
+
const isNegated = label.startsWith("N_");
|
|
4048
|
+
const displayLabel = isNegated ? label.slice(2) : label;
|
|
4028
4049
|
svgObjects.push({
|
|
4029
4050
|
name: "text",
|
|
4030
4051
|
type: "element",
|
|
@@ -4032,7 +4053,7 @@ var createSvgObjectsForSchPortPinLabel = (params) => {
|
|
|
4032
4053
|
class: "pin-number",
|
|
4033
4054
|
x: screenPinNumberTextPos.x.toString(),
|
|
4034
4055
|
y: screenPinNumberTextPos.y.toString(),
|
|
4035
|
-
style:
|
|
4056
|
+
style: `font-family: sans-serif;${isNegated ? " text-decoration: overline;" : ""}`,
|
|
4036
4057
|
fill: colorMap.schematic.pin_number,
|
|
4037
4058
|
"text-anchor": schPort.side_of_component === "left" || schPort.side_of_component === "bottom" ? "start" : "end",
|
|
4038
4059
|
"dominant-baseline": "middle",
|
|
@@ -4042,7 +4063,7 @@ var createSvgObjectsForSchPortPinLabel = (params) => {
|
|
|
4042
4063
|
children: [
|
|
4043
4064
|
{
|
|
4044
4065
|
type: "text",
|
|
4045
|
-
value:
|
|
4066
|
+
value: displayLabel || "",
|
|
4046
4067
|
name: "",
|
|
4047
4068
|
attributes: {},
|
|
4048
4069
|
children: []
|
|
@@ -4594,6 +4615,8 @@ var createSvgObjectsForSchNetLabelWithSymbol = ({
|
|
|
4594
4615
|
colorMap: colorMap2
|
|
4595
4616
|
}) => {
|
|
4596
4617
|
if (!schNetLabel.text) return [];
|
|
4618
|
+
const isNegated = schNetLabel.text.startsWith("N_");
|
|
4619
|
+
const labelText = isNegated ? schNetLabel.text.slice(2) : schNetLabel.text;
|
|
4597
4620
|
const svgObjects = [];
|
|
4598
4621
|
const symbol = symbols3[schNetLabel.symbol_name];
|
|
4599
4622
|
if (!symbol) {
|
|
@@ -4617,8 +4640,8 @@ var createSvgObjectsForSchNetLabelWithSymbol = ({
|
|
|
4617
4640
|
maxY: Math.max(...symbolPaths.flatMap((p) => p.points.map((pt) => pt.y)))
|
|
4618
4641
|
};
|
|
4619
4642
|
const fontSizeMm = getSchMmFontSize("net_label");
|
|
4620
|
-
const textWidthFSR = estimateTextWidth(
|
|
4621
|
-
const fullWidthFsr = textWidthFSR + ARROW_POINT_WIDTH_FSR * 2 + END_PADDING_EXTRA_PER_CHARACTER_FSR *
|
|
4643
|
+
const textWidthFSR = estimateTextWidth(labelText || "");
|
|
4644
|
+
const fullWidthFsr = textWidthFSR + ARROW_POINT_WIDTH_FSR * 2 + END_PADDING_EXTRA_PER_CHARACTER_FSR * labelText.length + END_PADDING_FSR;
|
|
4622
4645
|
const realTextGrowthVec = getUnitVectorFromOutsideToEdge(
|
|
4623
4646
|
schNetLabel.anchor_side
|
|
4624
4647
|
);
|
|
@@ -4719,7 +4742,7 @@ var createSvgObjectsForSchNetLabelWithSymbol = ({
|
|
|
4719
4742
|
);
|
|
4720
4743
|
let textValue = text.text;
|
|
4721
4744
|
if (textValue === "{REF}") {
|
|
4722
|
-
textValue =
|
|
4745
|
+
textValue = labelText || "";
|
|
4723
4746
|
} else if (textValue === "{VAL}") {
|
|
4724
4747
|
textValue = "";
|
|
4725
4748
|
}
|
|
@@ -4739,7 +4762,8 @@ var createSvgObjectsForSchNetLabelWithSymbol = ({
|
|
|
4739
4762
|
"font-family": "sans-serif",
|
|
4740
4763
|
"text-anchor": ninePointAnchorToTextAnchor[text.anchor],
|
|
4741
4764
|
"dominant-baseline": ninePointAnchorToDominantBaseline[text.anchor],
|
|
4742
|
-
"font-size": `${getSchScreenFontSize(realToScreenTransform, "reference_designator")}px
|
|
4765
|
+
"font-size": `${getSchScreenFontSize(realToScreenTransform, "reference_designator")}px`,
|
|
4766
|
+
...isNegated && textValue === labelText ? { style: "text-decoration: overline;" } : {}
|
|
4743
4767
|
},
|
|
4744
4768
|
children: [
|
|
4745
4769
|
{
|
|
@@ -4810,6 +4834,8 @@ var createSvgObjectsForSchNetLabel = ({
|
|
|
4810
4834
|
colorMap: colorMap2
|
|
4811
4835
|
}) => {
|
|
4812
4836
|
if (!schNetLabel.text) return [];
|
|
4837
|
+
const isNegated = schNetLabel.text.startsWith("N_");
|
|
4838
|
+
const labelText = isNegated ? schNetLabel.text.slice(2) : schNetLabel.text;
|
|
4813
4839
|
if (schNetLabel.symbol_name) {
|
|
4814
4840
|
return createSvgObjectsForSchNetLabelWithSymbol({
|
|
4815
4841
|
schNetLabel,
|
|
@@ -4820,14 +4846,14 @@ var createSvgObjectsForSchNetLabel = ({
|
|
|
4820
4846
|
const svgObjects = [];
|
|
4821
4847
|
const fontSizePx = getSchScreenFontSize(realToScreenTransform, "net_label");
|
|
4822
4848
|
const fontSizeMm = getSchMmFontSize("net_label");
|
|
4823
|
-
const textWidthFSR = estimateTextWidth(
|
|
4849
|
+
const textWidthFSR = estimateTextWidth(labelText || "");
|
|
4824
4850
|
const screenCenter = applyToPoint37(realToScreenTransform, schNetLabel.center);
|
|
4825
4851
|
const realTextGrowthVec = getUnitVectorFromOutsideToEdge(
|
|
4826
4852
|
schNetLabel.anchor_side
|
|
4827
4853
|
);
|
|
4828
4854
|
const screenTextGrowthVec = { ...realTextGrowthVec };
|
|
4829
4855
|
screenTextGrowthVec.y *= -1;
|
|
4830
|
-
const fullWidthFsr = textWidthFSR + ARROW_POINT_WIDTH_FSR * 2 + END_PADDING_EXTRA_PER_CHARACTER_FSR *
|
|
4856
|
+
const fullWidthFsr = textWidthFSR + ARROW_POINT_WIDTH_FSR * 2 + END_PADDING_EXTRA_PER_CHARACTER_FSR * labelText.length + END_PADDING_FSR;
|
|
4831
4857
|
const screenAnchorPosition = schNetLabel.anchor_position ? applyToPoint37(realToScreenTransform, schNetLabel.anchor_position) : {
|
|
4832
4858
|
x: screenCenter.x - screenTextGrowthVec.x * fullWidthFsr * fontSizePx / 2,
|
|
4833
4859
|
y: screenCenter.y - screenTextGrowthVec.y * fullWidthFsr * fontSizePx / 2
|
|
@@ -4855,12 +4881,12 @@ var createSvgObjectsForSchNetLabel = ({
|
|
|
4855
4881
|
},
|
|
4856
4882
|
// Top right corner in font-relative coordinates
|
|
4857
4883
|
{
|
|
4858
|
-
x: ARROW_POINT_WIDTH_FSR * 2 + END_PADDING_FSR + END_PADDING_EXTRA_PER_CHARACTER_FSR *
|
|
4884
|
+
x: ARROW_POINT_WIDTH_FSR * 2 + END_PADDING_FSR + END_PADDING_EXTRA_PER_CHARACTER_FSR * labelText.length + textWidthFSR,
|
|
4859
4885
|
y: 0.6
|
|
4860
4886
|
},
|
|
4861
4887
|
// Bottom right corner in font-relative coordinates
|
|
4862
4888
|
{
|
|
4863
|
-
x: ARROW_POINT_WIDTH_FSR * 2 + END_PADDING_FSR + END_PADDING_EXTRA_PER_CHARACTER_FSR *
|
|
4889
|
+
x: ARROW_POINT_WIDTH_FSR * 2 + END_PADDING_FSR + END_PADDING_EXTRA_PER_CHARACTER_FSR * labelText.length + textWidthFSR,
|
|
4864
4890
|
y: -0.6
|
|
4865
4891
|
},
|
|
4866
4892
|
// Bottom left corner in font-relative coordinates
|
|
@@ -4929,12 +4955,13 @@ var createSvgObjectsForSchNetLabel = ({
|
|
|
4929
4955
|
"font-family": "sans-serif",
|
|
4930
4956
|
"font-variant-numeric": "tabular-nums",
|
|
4931
4957
|
"font-size": `${fontSizePx}px`,
|
|
4932
|
-
transform: textTransformString
|
|
4958
|
+
transform: textTransformString,
|
|
4959
|
+
...isNegated ? { style: "text-decoration: overline;" } : {}
|
|
4933
4960
|
},
|
|
4934
4961
|
children: [
|
|
4935
4962
|
{
|
|
4936
4963
|
type: "text",
|
|
4937
|
-
value:
|
|
4964
|
+
value: labelText || "",
|
|
4938
4965
|
name: "",
|
|
4939
4966
|
attributes: {},
|
|
4940
4967
|
children: []
|