@dloizides/poster-render 0.14.0 → 0.14.2

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/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.14.2
4
+
5
+ - FLIER-SIZE-1 "Line size jumps at 101%": sizeScale multiplies the line's fitted size, so 100% to 101% is a 1% change (first published here; 0.14.1 never reached npm).
6
+ - POSTER-LINUX-1 "poster-render tests pass on Linux CI": the suite registers bundled OFL theme fonts and passes on Linux and Windows, so the release builds through GitHub Actions trusted publishing.
7
+
3
8
  ## 0.13.1
4
9
 
5
10
  - D-SPACE-1 "Space above/below applies per item": a wrapped line keeps `spaceAbove` on its first part and `spaceBelow` on its last, so a wrapped includes item's own lines stay tight.
package/dist/index.js CHANGED
@@ -814,21 +814,20 @@ function styled(line, key, sc) {
814
814
  if (style === void 0 && widthTie === void 0 && sizeTie === void 0) {
815
815
  return { ...line, key };
816
816
  }
817
- const size = line.size * (style?.sizeScale ?? 1);
817
+ const scaled = line.size * (style?.sizeScale ?? 1);
818
818
  return {
819
819
  ...line,
820
820
  key,
821
- size,
822
821
  color: style?.color ?? line.color,
823
822
  weight: style?.weight ?? line.weight,
824
823
  family: style?.font,
825
824
  italic: style?.italic,
826
825
  spacing: style?.letterSpacing,
827
826
  widthScale: style?.widthScale,
828
- fixedSize: style?.sizeScale === void 0 ? void 0 : true,
827
+ sizeScale: style?.sizeScale,
829
828
  align: style?.align,
830
- spaceAbove: style?.spaceAbove === void 0 ? void 0 : style.spaceAbove * size,
831
- spaceBelow: style?.spaceBelow === void 0 ? void 0 : style.spaceBelow * size,
829
+ spaceAbove: style?.spaceAbove === void 0 ? void 0 : style.spaceAbove * scaled,
830
+ spaceBelow: style?.spaceBelow === void 0 ? void 0 : style.spaceBelow * scaled,
832
831
  widthTie,
833
832
  sizeTie
834
833
  };
@@ -1069,9 +1068,6 @@ function groupBox(group, k, colW) {
1069
1068
  return { pad, d, iconIndent, avail: colW - 2 * pad - iconIndent };
1070
1069
  }
1071
1070
  function lineSize(line, width, k, avail) {
1072
- if (line.fixedSize === true) {
1073
- return line.size;
1074
- }
1075
1071
  const indent = bulletIndent(line, k);
1076
1072
  return Math.max(0, Math.min(line.size * k, line.size * (avail - indent) / Math.max(width, 1)));
1077
1073
  }
@@ -1081,7 +1077,7 @@ function groupSizes(m, k, avail) {
1081
1077
  return own;
1082
1078
  }
1083
1079
  const ratio = Math.min(...m.group.lines.map((line, i) => (own[i] ?? 0) / line.size));
1084
- return m.group.lines.map((line) => line.fixedSize === true ? line.size : line.size * ratio);
1080
+ return m.group.lines.map((line) => line.size * ratio);
1085
1081
  }
1086
1082
  function tieMembers(all, k, colW, table, pick) {
1087
1083
  const byId = /* @__PURE__ */ new Map();
@@ -1090,7 +1086,7 @@ function tieMembers(all, k, colW, table, pick) {
1090
1086
  const sizes = table.get(m) ?? [];
1091
1087
  m.group.lines.forEach((line, i) => {
1092
1088
  const id = pick(line);
1093
- if (id !== void 0 && line.fixedSize !== true) {
1089
+ if (id !== void 0) {
1094
1090
  const member = { line, width: Math.max(m.widths[i] ?? 1, 1), cap: Math.max(0, Math.min(1, line.widthScale ?? 1) * avail - bulletIndent(line, k)), sizes, i };
1095
1091
  byId.set(id, [...byId.get(id) ?? [], member]);
1096
1092
  }
@@ -1111,11 +1107,14 @@ function sameWidths(list) {
1111
1107
  x.sizes[x.i] = target * x.line.size / x.width;
1112
1108
  });
1113
1109
  }
1110
+ function applyScales(m, sizes) {
1111
+ return sizes.map((size, i) => size * (m.group.lines[i]?.sizeScale ?? 1));
1112
+ }
1114
1113
  function sizeTable(all, k, colW) {
1115
1114
  const table = new Map(all.map((m) => [m, groupSizes(m, k, groupBox(m.group, k, colW).avail)]));
1116
1115
  tieMembers(all, k, colW, table, (line) => line.sizeTie).forEach(sameSizes);
1117
1116
  tieMembers(all, k, colW, table, (line) => line.widthTie).forEach(sameWidths);
1118
- return table;
1117
+ return new Map(all.map((m) => [m, applyScales(m, table.get(m) ?? [])]));
1119
1118
  }
1120
1119
 
1121
1120
  // src/layout/textFlow.ts
@@ -1175,11 +1174,11 @@ function placeGroup(m, at, out) {
1175
1174
  group.lines.forEach((line, i) => {
1176
1175
  const size = sizes[i] ?? 0;
1177
1176
  y += (line.spaceAbove ?? 0) * k;
1178
- const indent = (indented(line) ? line.size * k * BULLET_INDENT : 0) + iconIndent;
1177
+ const indent = (indented(line) ? line.size * (line.sizeScale ?? 1) * k * BULLET_INDENT : 0) + iconIndent;
1179
1178
  const w = (m.widths[i] ?? 0) * size / line.size;
1180
1179
  const x = lineX(line, { col, pad, indent, w });
1181
1180
  const box = { x, y, w, h: size * LINE_HEIGHT };
1182
- out?.texts.push({ text: line.text, font: "", color: line.color, box, key: line.key, ...line.fixedSize === true ? { fixed: true } : {}, ...runsOf(line, box, m.cuts?.[i], size / line.size) });
1181
+ out?.texts.push({ text: line.text, font: "", color: line.color, box, key: line.key, ...line.sizeScale === void 0 ? {} : { fixed: true }, ...runsOf(line, box, m.cuts?.[i], size / line.size) });
1183
1182
  if (line.bullet && out) {
1184
1183
  out.bullets.push({ x: col.x + pad + size * BULLET_RADIUS, y: y + size * LINE_HEIGHT / 2, r: size * BULLET_RADIUS, color: line.bullet });
1185
1184
  }