@dloizides/poster-render 0.10.0 → 0.11.0

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.d.mts CHANGED
@@ -181,10 +181,11 @@ interface FlierDoc {
181
181
  }
182
182
  /** A text line path such as "title", "venue.1", "schedule.0.time" or "items.2.date" (see LINE_KEY_PATTERN). */
183
183
  type LineKey = string;
184
- /** Optional per-line overrides of the theme; an absent field keeps the theme value. letterSpacing is in em. */
184
+ /** Optional per-line overrides of the theme; an absent field keeps the theme value. letterSpacing is in em; widthScale widens or narrows the room the line may fill. */
185
185
  interface LineStyle {
186
186
  font?: string;
187
187
  sizeScale?: number;
188
+ widthScale?: number;
188
189
  color?: string;
189
190
  weight?: number;
190
191
  italic?: boolean;
package/dist/index.d.ts CHANGED
@@ -181,10 +181,11 @@ interface FlierDoc {
181
181
  }
182
182
  /** A text line path such as "title", "venue.1", "schedule.0.time" or "items.2.date" (see LINE_KEY_PATTERN). */
183
183
  type LineKey = string;
184
- /** Optional per-line overrides of the theme; an absent field keeps the theme value. letterSpacing is in em. */
184
+ /** Optional per-line overrides of the theme; an absent field keeps the theme value. letterSpacing is in em; widthScale widens or narrows the room the line may fill. */
185
185
  interface LineStyle {
186
186
  font?: string;
187
187
  sizeScale?: number;
188
+ widthScale?: number;
188
189
  color?: string;
189
190
  weight?: number;
190
191
  italic?: boolean;
package/dist/index.js CHANGED
@@ -90,6 +90,8 @@ var LINE_KEY_PATTERN = "^(title|titleBottom|script|footer|includes[.]heading|inc
90
90
  var MAX_FONT = 40;
91
91
  var MIN_SIZE_SCALE = 0.25;
92
92
  var MAX_SIZE_SCALE = 3;
93
+ var MIN_WIDTH_SCALE = 0.5;
94
+ var MAX_WIDTH_SCALE = 1.5;
93
95
  var MIN_SPACING = -0.1;
94
96
  var MAX_SPACING = 0.5;
95
97
  var MAX_TIES = 12;
@@ -101,6 +103,7 @@ var lineStyle = {
101
103
  properties: {
102
104
  font: { type: "string", minLength: 1, maxLength: MAX_FONT, pattern: "^[A-Za-z0-9 ]+$" },
103
105
  sizeScale: { type: "number", minimum: MIN_SIZE_SCALE, maximum: MAX_SIZE_SCALE },
106
+ widthScale: { type: "number", minimum: MIN_WIDTH_SCALE, maximum: MAX_WIDTH_SCALE },
104
107
  color: { type: "string", pattern: "^#[0-9a-fA-F]{6}$" },
105
108
  weight: { type: "integer", enum: WEIGHTS },
106
109
  italic: { type: "boolean" },
@@ -805,6 +808,7 @@ function styled(line, key, sc) {
805
808
  family: style?.font,
806
809
  italic: style?.italic,
807
810
  spacing: style?.letterSpacing,
811
+ widthScale: style?.widthScale,
808
812
  align: style?.align,
809
813
  widthTie,
810
814
  sizeTie
@@ -985,7 +989,7 @@ function groupBox(group, k, colW) {
985
989
  }
986
990
  function lineSize(line, width, k, avail) {
987
991
  const indent = bulletIndent(line, k);
988
- return Math.max(0, Math.min(line.size * k, line.size * (avail - indent) / Math.max(width, 1)));
992
+ return Math.max(0, Math.min(line.size * k, line.size * (avail * (line.widthScale ?? 1) - indent) / Math.max(width, 1)));
989
993
  }
990
994
  function groupSizes(m, k, avail) {
991
995
  const own = m.group.lines.map((line, i) => lineSize(line, m.widths[i] ?? 1, k, avail));
@@ -1003,7 +1007,7 @@ function tieMembers(all, k, colW, table, pick) {
1003
1007
  m.group.lines.forEach((line, i) => {
1004
1008
  const id = pick(line);
1005
1009
  if (id !== void 0) {
1006
- const member = { line, width: Math.max(m.widths[i] ?? 1, 1), cap: Math.max(0, avail - bulletIndent(line, k)), sizes, i };
1010
+ const member = { line, width: Math.max(m.widths[i] ?? 1, 1), cap: Math.max(0, avail * (line.widthScale ?? 1) - bulletIndent(line, k)), sizes, i };
1007
1011
  byId.set(id, [...byId.get(id) ?? [], member]);
1008
1012
  }
1009
1013
  });