← Commit history

2.27.1: margin for NAME/VALUE; captions count as ink

John Lauer ·66071a690f ·1mo ago ·parent e2d7196
7 files changed +45−11
Cargo.lock+1−1
@@ -10,7 +10,7 @@ checksum = "320119579fcad9c21884f5c4861d16174d0e06250625266f50fe6898340abefa"  [[package]] name = "adom-lbr"-version = "2.27.0"+version = "2.27.1" dependencies = [  "altium-codec",  "anyhow",
Cargo.toml+1−1
@@ -1,6 +1,6 @@ [package] name = "adom-lbr"-version = "2.27.0"+version = "2.27.1" edition = "2021" description = "adom-lbr generator / EDA translator: the canonical adom-lbr JSON is the hub, with native converters to Altium (.SchLib/.PcbLib/.IntLib), EAGLE/Fusion (.lbr), and KiCad. Altium output is written natively — no Altium needed at conversion time." 
VERSION+1−1
@@ -1 +1 @@-2.27.0+2.27.1
bin/adom-lbr
⋯ 1 unchanged line ⋯
package.json+1−1
@@ -1,6 +1,6 @@ {   "slug": "adom-lbr",-  "version": "2.27.0",+  "version": "2.27.1",   "type": "app",   "description": "adom-lbr \u2014 the EDA library translator. Bring a component in from any supported EDA tool and convert it to any other (KiCad \u21c4 Altium \u21c4 EAGLE/Fusion) through one canonical adom-lbr JSON \u2014 symbol + footprint + 3D + pin\u2194pad map. Altium is written natively (no Altium needed). Includes the adom-lbr Manager: browse wiki components and view symbol/footprint/3D + the per-EDA layer stackup.",   "dependencies": {},
page.json+2−2
@@ -1,6 +1,6 @@ {   "slug": "adom-lbr",-  "version": "2.27.0",+  "version": "2.27.1",   "type": "app",   "description": "adom-lbr — the EDA library translator. Bring a component in from any supported EDA tool and convert it to any other (KiCad ⇄ Altium ⇄ EAGLE/Fusion) through one canonical adom-lbr JSON — symbol + footprint + 3D + pin↔pad map. Altium is written natively (no Altium needed). Includes the adom-lbr Manager: browse wiki components and view symbol/footprint/3D + the per-EDA layer stackup.",   "dependencies": {},@@ -88,4 +88,4 @@       "label": "Browse parts"     }   ]-}\ No newline at end of file+}
src/main.rs+39−5
@@ -1729,12 +1729,46 @@ fn emit_symbol_block(xml: &mut String, sym: &ParsedSymbol, symbol_art: Option<&S             };             let l = b.left + inset(&|p: &KicadPin| p.angle == 0);             let r = b.right - inset(&|p: &KicadPin| p.angle == 180);-            let t = b.top - inset(&|p: &KicadPin| p.angle == 270);-            let bo = b.bottom + inset(&|p: &KicadPin| p.angle == 90);+            let mut t = b.top - inset(&|p: &KicadPin| p.angle == 270);+            let mut bo = b.bottom + inset(&|p: &KicadPin| p.angle == 90);             let cx = (l + r) / 2.0;-            if t - bo >= 2.0 * 1.27 && r - l >= 4.0 {-                xml.push_str(&format!("  <text x=\"{:.4}\" y=\"{:.4}\" size=\"1.27\" layer=\"95\" align=\"top-center\">&gt;NAME</text>\n", cx, t));-                xml.push_str(&format!("  <text x=\"{:.4}\" y=\"{:.4}\" size=\"1.27\" layer=\"96\" align=\"bottom-center\">&gt;VALUE</text>\n", cx, bo));++            // THE NEAREST INK IS NOT ALWAYS A PIN NAME. On the grouped layouts a group+            // caption sits above or below the pin names, so it, not the name, is what a+            // label would crowd. Pull the rect in past any caption that shares the labels'+            // horizontal span. A caption's own extent depends on how it is anchored: an+            // unrotated one is centred on its y, a rotated top one hangs DOWN from its y,+            // a rotated bottom one runs UP from it.+            let cap_h = 0.762;+            let label_half_w = 6.0 * 0.6 * 1.27 / 2.0;      // ">VALUE" is the wider of the two+            for g in &sym.group_labels {+                let len = g.text.chars().count() as f64 * 0.6 * cap_h;+                let (gy0, gy1) = if g.angle == 90 || g.angle == 270 {+                    if g.justify_right { (g.y - len, g.y) } else { (g.y, g.y + len) }+                } else {+                    (g.y - cap_h / 2.0, g.y + cap_h / 2.0)+                };+                let (gx0, gx1) = if g.angle == 90 || g.angle == 270 {+                    (g.x - cap_h / 2.0, g.x + cap_h / 2.0)+                } else if g.justify_right {+                    (g.x - len, g.x)+                } else {+                    (g.x, g.x + len)+                };+                if gx1 < cx - label_half_w || gx0 > cx + label_half_w { continue; }+                let mid = (b.top + b.bottom) / 2.0;+                if gy0 > mid { t = t.min(gy0); } else { bo = bo.max(gy1); }+            }++            // BREATHING ROOM, ON THE GRID. Sitting exactly on the rect edge puts the label+            // flush against the ink below it, which reads as crowded even though nothing+            // overlaps (John, on the SQG frame). One full text height of gap, snapped to+            // EAGLE's 2.54 mm grid so the labels land where a user's own text would.+            const MARGIN: f64 = 2.54;+            let (ny, vy) = (t - MARGIN, bo + MARGIN);+            if ny - vy >= 2.0 * 1.27 && r - l >= 4.0 {+                xml.push_str(&format!("  <text x=\"{:.4}\" y=\"{:.4}\" size=\"1.27\" layer=\"95\" align=\"top-center\">&gt;NAME</text>\n", cx, ny));+                xml.push_str(&format!("  <text x=\"{:.4}\" y=\"{:.4}\" size=\"1.27\" layer=\"96\" align=\"bottom-center\">&gt;VALUE</text>\n", cx, vy));             } else {                 // The interior is too small for 1.27 mm text (a tiny square symbol). Put the                 // labels in the corners BEYOND the pin extents, where a wire still cannot go.