circuit-to-svg 0.0.295 → 0.0.296

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 CHANGED
@@ -2751,12 +2751,13 @@ var CHAR_WIDTH = 1;
2751
2751
  var CHAR_SPACING = 0.2;
2752
2752
  var LINE_HEIGHT = 1.4;
2753
2753
  var FONT_SCALE = 0.53;
2754
- function linesToPathData(lines, offsetX, offsetY, charScale) {
2754
+ var BASELINE_Y = 0.241;
2755
+ function linesToPathData(lines, offsetX, offsetY, charScale, baselineAdjust = 0) {
2755
2756
  return lines.map((line) => {
2756
2757
  const x1 = offsetX + line.x1 * charScale;
2757
- const y1 = offsetY + (1 - line.y1) * charScale;
2758
+ const y1 = offsetY + (1 - line.y1 + baselineAdjust) * charScale;
2758
2759
  const x2 = offsetX + line.x2 * charScale;
2759
- const y2 = offsetY + (1 - line.y2) * charScale;
2760
+ const y2 = offsetY + (1 - line.y2 + baselineAdjust) * charScale;
2760
2761
  return `M${x1} ${y1}L${x2} ${y2}`;
2761
2762
  }).join(" ");
2762
2763
  }
@@ -2771,7 +2772,9 @@ function textToAlphabetPath(text, fontSize) {
2771
2772
  }
2772
2773
  const lines = lineAlphabet[char];
2773
2774
  if (lines) {
2774
- paths.push(linesToPathData(lines, x, 0, fontSize));
2775
+ const isLowercase = char >= "a" && char <= "z";
2776
+ const baselineAdjust = isLowercase ? BASELINE_Y : 0;
2777
+ paths.push(linesToPathData(lines, x, 0, fontSize, baselineAdjust));
2775
2778
  }
2776
2779
  x += charAdvance;
2777
2780
  }
@@ -2804,7 +2807,9 @@ function textToCenteredAlphabetPaths(text, fontSize) {
2804
2807
  }
2805
2808
  const charLines = lineAlphabet[char];
2806
2809
  if (charLines) {
2807
- paths.push(linesToPathData(charLines, x, y, fontSize));
2810
+ const isLowercase = char >= "a" && char <= "z";
2811
+ const baselineAdjust = isLowercase ? BASELINE_Y : 0;
2812
+ paths.push(linesToPathData(charLines, x, y, fontSize, baselineAdjust));
2808
2813
  }
2809
2814
  x += charAdvance;
2810
2815
  }
@@ -2875,7 +2880,6 @@ function createSvgObjectsFromPcbCopperText(pcbCopperText, ctx) {
2875
2880
  id: maskId
2876
2881
  },
2877
2882
  children: [
2878
- // White background - area that will show copper
2879
2883
  {
2880
2884
  name: "rect",
2881
2885
  type: "element",
@@ -2889,7 +2893,6 @@ function createSvgObjectsFromPcbCopperText(pcbCopperText, ctx) {
2889
2893
  },
2890
2894
  children: []
2891
2895
  },
2892
- // Black text strokes - area that will be cut out
2893
2896
  {
2894
2897
  name: "path",
2895
2898
  type: "element",
@@ -5562,7 +5565,7 @@ function getSoftwareUsedString(circuitJson) {
5562
5565
  var package_default = {
5563
5566
  name: "circuit-to-svg",
5564
5567
  type: "module",
5565
- version: "0.0.294",
5568
+ version: "0.0.295",
5566
5569
  description: "Convert Circuit JSON to SVG",
5567
5570
  main: "dist/index.js",
5568
5571
  files: [