← Commit history

2.28.1: correct glyph advance; label-to-label clearance

John Lauer ·dc4200cdb1 ·1mo ago ·parent 39c33ed
7 files changed +22−10
Cargo.lock+1−1
@@ -10,7 +10,7 @@ checksum = "320119579fcad9c21884f5c4861d16174d0e06250625266f50fe6898340abefa"  [[package]] name = "adom-lbr"-version = "2.28.0"+version = "2.28.1" dependencies = [  "altium-codec",  "anyhow",
Cargo.toml+1−1
@@ -1,6 +1,6 @@ [package] name = "adom-lbr"-version = "2.28.0"+version = "2.28.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.28.0+2.28.1
bin/adom-lbr
⋯ 1 unchanged line ⋯
package.json+1−1
@@ -1,6 +1,6 @@ {   "slug": "adom-lbr",-  "version": "2.28.0",+  "version": "2.28.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.28.0",+  "version": "2.28.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+16−4
@@ -1780,7 +1780,16 @@ fn emit_symbol_block(xml: &mut String, sym: &ParsedSymbol, symbol_art: Option<&S         println!("HINT: >NAME/>VALUE placed from the outline contract (adom-symbol's own designator points), so the KiCad and Fusion renders match.");     } else {     let has_vertical_pins = sym.pins.iter().any(|p| p.angle == 90 || p.angle == 270);-    let pin_name_w = |p: &KicadPin| dedup_pin_names(std::slice::from_ref(p))[0].chars().count() as f64 * 0.6 * 1.778;+    // GLYPH ADVANCE, taken from adom-symbol rather than from my own estimate. I used+    // 0.6 x height, which is the usual approximation for EAGLE's vector font and is roughly+    // HALF what Fusion actually draws: on the CH340G-SQ frame that made >NAME land against+    // the bottom of "R232" while my arithmetic claimed 2.69 mm of clearance. adom-symbol+    // measures 1.5 mm per character at the 1.27 mm font, so about 1.18 x height, and its+    // margins read correctly in Fusion. One model, and it is the one that has been checked+    // against the renderer. Over-reserving is the safe direction: it costs interior space,+    // never a collision.+    const GLYPH_ADVANCE: f64 = 1.18;+    let pin_name_w = |p: &KicadPin| dedup_pin_names(std::slice::from_ref(p))[0].chars().count() as f64 * GLYPH_ADVANCE * 1.778;     match (&sym.body, has_vertical_pins) {         (Some(b), true) => {             // Interior free rect: pull each side in by that side's longest pin name plus@@ -1802,9 +1811,9 @@ fn emit_symbol_block(xml: &mut String, sym: &ParsedSymbol, symbol_art: Option<&S             // 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+            let label_half_w = 6.0 * GLYPH_ADVANCE * 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 len = g.text.chars().count() as f64 * GLYPH_ADVANCE * 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 {@@ -1828,7 +1837,10 @@ fn emit_symbol_block(xml: &mut String, sym: &ParsedSymbol, symbol_art: Option<&S             // 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 {+            // The two labels must clear EACH OTHER as well as the ink around them: a rect+            // that fits them only by letting them touch is the squeeze the corner fallback+            // exists to avoid. Two text heights plus a gap of one.+            if ny - vy >= 3.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 {