Skip to content

Commit 25bae7b

Browse files
committed
Refine silkscreen scaling for small footprints
1 parent 688c631 commit 25bae7b

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

src/convert-kicad-json-to-tscircuit-soup.ts

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -776,15 +776,17 @@ export const convertKicadJsonToTsCircuitSoup = async (
776776
pcbComponent.height = componentHeight
777777

778778
const computeDynamicFontSize = () => {
779-
const effectiveSize =
780-
componentWidth > 0 && componentHeight > 0
781-
? Math.sqrt(componentWidth * componentHeight)
782-
: Math.max(componentWidth, componentHeight)
783-
if (!effectiveSize || !Number.isFinite(effectiveSize)) {
784-
return 1.27
785-
}
786-
const scaled = effectiveSize * 0.35
787-
return Math.min(Math.max(scaled, 0.5), 2.5)
779+
const baseFontSize = 1.27
780+
const usableDimensions = [componentWidth, componentHeight].filter(
781+
(value) => Number.isFinite(value) && value > 0,
782+
)
783+
784+
if (usableDimensions.length === 0) return baseFontSize
785+
786+
const smallestDimension = Math.min(...usableDimensions)
787+
const scaled = smallestDimension * 0.4
788+
789+
return Math.max(Math.min(scaled, baseFontSize), 0.3)
788790
}
789791

790792
for (const fp_text of fp_texts) {
Lines changed: 1 addition & 1 deletion
Loading

0 commit comments

Comments
 (0)