Skip to content

Commit

Permalink
add silkscreen text rendering
Browse files Browse the repository at this point in the history
  • Loading branch information
seveibar committed Jun 7, 2024
1 parent 3010250 commit 509b630
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
17 changes: 17 additions & 0 deletions src/convert-kicad-json-to-tscircuit-soup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@ const debug = Debug("kicad-mod-converter")
export const convertKicadLayerToTscircuitLayer = (kicadLayer: string) => {
switch (kicadLayer) {
case "F.Cu":
case "F.Fab":
case "F.SilkS":
return "top"
case "B.Cu":
case "B.Fab":
case "B.SilkS":
return "bottom"
}
Expand Down Expand Up @@ -66,6 +68,21 @@ export const convertKicadJsonToTsCircuitSoup = async (
debug("Unhandled layer for fp_line", fp_line.layer)
}
}

for (const fp_text of fp_texts) {
cb.footprint.add("silkscreentext", (pb) =>
pb.setProps({
text: fp_text.text,
pcbX: fp_text.at[0],
pcbY: -fp_text.at[1],
layer: convertKicadLayerToTscircuitLayer(fp_text.layer)!,
fontSize: fp_text.effects?.font.size[0],

Check failure on line 79 in src/convert-kicad-json-to-tscircuit-soup.ts

View workflow job for this annotation

GitHub Actions / publish

'fp_text.effects.font' is possibly 'undefined'.

// TODO
// rotation: fp_text.angle,
})
)
}
})

const soup = await pb.build()
Expand Down
2 changes: 1 addition & 1 deletion src/parse-kicad-mod-to-kicad-json.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ export const parseKicadModToKicadJson = (fileContent: string): KicadModJson => {
const fp_texts: FpText[] = []

for (const fp_text_row of fp_texts_rows) {
const text = fp_text_row[1].valueOf()
const text = fp_text_row[2].valueOf()
const at = getAttr(fp_text_row, "at")
const layer = getAttr(fp_text_row, "layer")
const uuid = getAttr(fp_text_row, "uuid")
Expand Down

0 comments on commit 509b630

Please sign in to comment.