altium-to-circuit-json 0.0.72 → 0.0.74

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
@@ -2911,6 +2911,46 @@ function selectCircuitJsonSymbol({
2911
2911
  )[0];
2912
2912
  }
2913
2913
 
2914
+ // lib/schematic/components/getAltiumPinNameFontSize.ts
2915
+ var DEFAULT_SCHEMATIC_FONT_ID = 0;
2916
+ var DEFAULT_SCHEMATIC_FONT_SIZE = 10;
2917
+ var PIN_CUSTOM_FONT_ID_FLAG = 16;
2918
+ var readSchematicInteger = (raw, fallback) => {
2919
+ const parsed = Number(raw);
2920
+ return Number.isFinite(parsed) ? Math.round(parsed) : fallback;
2921
+ };
2922
+ function getAltiumPinNameFontSize({
2923
+ pin,
2924
+ sheetRecord
2925
+ }) {
2926
+ const systemFontId = readSchematicInteger(
2927
+ sheetRecord?.getCaseInsensitive("SYSTEMFONT"),
2928
+ DEFAULT_SCHEMATIC_FONT_ID
2929
+ );
2930
+ const namePositionFlags = readSchematicInteger(
2931
+ pin.getCaseInsensitive("PINNAME_POSITIONCONGLOMERATE"),
2932
+ 0
2933
+ );
2934
+ const hasCustomNameFont = (namePositionFlags & PIN_CUSTOM_FONT_ID_FLAG) !== 0;
2935
+ const recordFontId = readSchematicInteger(
2936
+ pin.getCaseInsensitive("FONTID"),
2937
+ systemFontId
2938
+ );
2939
+ const isLegacyPin = pin.getCaseInsensitive("PINNAME_POSITIONCONGLOMERATE") === void 0 && pin.getCaseInsensitive("PINDESIGNATOR_POSITIONCONGLOMERATE") === void 0;
2940
+ const hasLegacyFont = sheetRecord?.getCaseInsensitive(`SIZE${recordFontId}`) !== void 0;
2941
+ const inheritedFontId = isLegacyPin && hasLegacyFont ? recordFontId : systemFontId;
2942
+ const requestedFontId = hasCustomNameFont ? readSchematicInteger(
2943
+ pin.getCaseInsensitive("NAME_CUSTOMFONTID"),
2944
+ systemFontId
2945
+ ) : inheritedFontId;
2946
+ const fontId = requestedFontId > 0 ? requestedFontId : systemFontId;
2947
+ const selectedSize = readSchematicInteger(
2948
+ sheetRecord?.getCaseInsensitive(`SIZE${fontId}`),
2949
+ DEFAULT_SCHEMATIC_FONT_SIZE
2950
+ );
2951
+ return selectedSize > 0 ? selectedSize : DEFAULT_SCHEMATIC_FONT_SIZE;
2952
+ }
2953
+
2914
2954
  // lib/schematic/components/parseAltiumPinLabel.ts
2915
2955
  function parseAltiumPinLabel(name) {
2916
2956
  if (!name.includes("\\")) return { displayText: name };
@@ -2957,6 +2997,7 @@ function convertComponentPin({
2957
2997
  pin,
2958
2998
  pinIndex,
2959
2999
  schematicComponentId,
3000
+ sheetRecord,
2960
3001
  sourceComponentId,
2961
3002
  visibleSymbolLabels
2962
3003
  }) {
@@ -2998,6 +3039,10 @@ function convertComponentPin({
2998
3039
  center: scalePoint(terminalPoint, options.scale),
2999
3040
  ...showName && name ? {
3000
3041
  display_pin_label: parsedPinLabel.displayText,
3042
+ display_pin_label_font_size: scaleLength(
3043
+ getAltiumPinNameFontSize({ pin, sheetRecord }),
3044
+ options.scale
3045
+ ),
3001
3046
  ...parsedPinLabel.textParts ? { display_pin_label_text_parts: parsedPinLabel.textParts } : {}
3002
3047
  } : {},
3003
3048
  distance_from_component_edge: scaleLength(pinLength, options.scale),
@@ -3675,6 +3720,7 @@ function convertComponent({
3675
3720
  pin,
3676
3721
  pinIndex,
3677
3722
  schematicComponentId: identity.schematicComponentId,
3723
+ sheetRecord: context.sheetRecord,
3678
3724
  sourceComponentId: identity.sourceComponentId,
3679
3725
  visibleSymbolLabels
3680
3726
  })
@@ -3761,6 +3807,9 @@ function convertComponents({
3761
3807
  options
3762
3808
  }) {
3763
3809
  const sourceComponentIdByDesignator = /* @__PURE__ */ new Map();
3810
+ const sheetRecord = document.records.find(
3811
+ (record) => record.recordKind === "31"
3812
+ );
3764
3813
  for (const [componentIndex, componentRecord] of document.records.entries()) {
3765
3814
  if (!(componentRecord instanceof AltiumSchComponentRecord)) continue;
3766
3815
  convertComponent(
@@ -3771,6 +3820,7 @@ function convertComponents({
3771
3820
  elements,
3772
3821
  handledRecords,
3773
3822
  options,
3823
+ sheetRecord,
3774
3824
  sourceComponentIdByDesignator
3775
3825
  }
3776
3826
  );