@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 +5 -0
- package/dist/index.js +12 -13
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +12 -13
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -812,21 +812,20 @@ function styled(line, key, sc) {
|
|
|
812
812
|
if (style === void 0 && widthTie === void 0 && sizeTie === void 0) {
|
|
813
813
|
return { ...line, key };
|
|
814
814
|
}
|
|
815
|
-
const
|
|
815
|
+
const scaled = line.size * (style?.sizeScale ?? 1);
|
|
816
816
|
return {
|
|
817
817
|
...line,
|
|
818
818
|
key,
|
|
819
|
-
size,
|
|
820
819
|
color: style?.color ?? line.color,
|
|
821
820
|
weight: style?.weight ?? line.weight,
|
|
822
821
|
family: style?.font,
|
|
823
822
|
italic: style?.italic,
|
|
824
823
|
spacing: style?.letterSpacing,
|
|
825
824
|
widthScale: style?.widthScale,
|
|
826
|
-
|
|
825
|
+
sizeScale: style?.sizeScale,
|
|
827
826
|
align: style?.align,
|
|
828
|
-
spaceAbove: style?.spaceAbove === void 0 ? void 0 : style.spaceAbove *
|
|
829
|
-
spaceBelow: style?.spaceBelow === void 0 ? void 0 : style.spaceBelow *
|
|
827
|
+
spaceAbove: style?.spaceAbove === void 0 ? void 0 : style.spaceAbove * scaled,
|
|
828
|
+
spaceBelow: style?.spaceBelow === void 0 ? void 0 : style.spaceBelow * scaled,
|
|
830
829
|
widthTie,
|
|
831
830
|
sizeTie
|
|
832
831
|
};
|
|
@@ -1067,9 +1066,6 @@ function groupBox(group, k, colW) {
|
|
|
1067
1066
|
return { pad, d, iconIndent, avail: colW - 2 * pad - iconIndent };
|
|
1068
1067
|
}
|
|
1069
1068
|
function lineSize(line, width, k, avail) {
|
|
1070
|
-
if (line.fixedSize === true) {
|
|
1071
|
-
return line.size;
|
|
1072
|
-
}
|
|
1073
1069
|
const indent = bulletIndent(line, k);
|
|
1074
1070
|
return Math.max(0, Math.min(line.size * k, line.size * (avail - indent) / Math.max(width, 1)));
|
|
1075
1071
|
}
|
|
@@ -1079,7 +1075,7 @@ function groupSizes(m, k, avail) {
|
|
|
1079
1075
|
return own;
|
|
1080
1076
|
}
|
|
1081
1077
|
const ratio = Math.min(...m.group.lines.map((line, i) => (own[i] ?? 0) / line.size));
|
|
1082
|
-
return m.group.lines.map((line) => line.
|
|
1078
|
+
return m.group.lines.map((line) => line.size * ratio);
|
|
1083
1079
|
}
|
|
1084
1080
|
function tieMembers(all, k, colW, table, pick) {
|
|
1085
1081
|
const byId = /* @__PURE__ */ new Map();
|
|
@@ -1088,7 +1084,7 @@ function tieMembers(all, k, colW, table, pick) {
|
|
|
1088
1084
|
const sizes = table.get(m) ?? [];
|
|
1089
1085
|
m.group.lines.forEach((line, i) => {
|
|
1090
1086
|
const id = pick(line);
|
|
1091
|
-
if (id !== void 0
|
|
1087
|
+
if (id !== void 0) {
|
|
1092
1088
|
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 };
|
|
1093
1089
|
byId.set(id, [...byId.get(id) ?? [], member]);
|
|
1094
1090
|
}
|
|
@@ -1109,11 +1105,14 @@ function sameWidths(list) {
|
|
|
1109
1105
|
x.sizes[x.i] = target * x.line.size / x.width;
|
|
1110
1106
|
});
|
|
1111
1107
|
}
|
|
1108
|
+
function applyScales(m, sizes) {
|
|
1109
|
+
return sizes.map((size, i) => size * (m.group.lines[i]?.sizeScale ?? 1));
|
|
1110
|
+
}
|
|
1112
1111
|
function sizeTable(all, k, colW) {
|
|
1113
1112
|
const table = new Map(all.map((m) => [m, groupSizes(m, k, groupBox(m.group, k, colW).avail)]));
|
|
1114
1113
|
tieMembers(all, k, colW, table, (line) => line.sizeTie).forEach(sameSizes);
|
|
1115
1114
|
tieMembers(all, k, colW, table, (line) => line.widthTie).forEach(sameWidths);
|
|
1116
|
-
return table;
|
|
1115
|
+
return new Map(all.map((m) => [m, applyScales(m, table.get(m) ?? [])]));
|
|
1117
1116
|
}
|
|
1118
1117
|
|
|
1119
1118
|
// src/layout/textFlow.ts
|
|
@@ -1173,11 +1172,11 @@ function placeGroup(m, at, out) {
|
|
|
1173
1172
|
group.lines.forEach((line, i) => {
|
|
1174
1173
|
const size = sizes[i] ?? 0;
|
|
1175
1174
|
y += (line.spaceAbove ?? 0) * k;
|
|
1176
|
-
const indent = (indented(line) ? line.size * k * BULLET_INDENT : 0) + iconIndent;
|
|
1175
|
+
const indent = (indented(line) ? line.size * (line.sizeScale ?? 1) * k * BULLET_INDENT : 0) + iconIndent;
|
|
1177
1176
|
const w = (m.widths[i] ?? 0) * size / line.size;
|
|
1178
1177
|
const x = lineX(line, { col, pad, indent, w });
|
|
1179
1178
|
const box = { x, y, w, h: size * LINE_HEIGHT };
|
|
1180
|
-
out?.texts.push({ text: line.text, font: "", color: line.color, box, key: line.key, ...line.
|
|
1179
|
+
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) });
|
|
1181
1180
|
if (line.bullet && out) {
|
|
1182
1181
|
out.bullets.push({ x: col.x + pad + size * BULLET_RADIUS, y: y + size * LINE_HEIGHT / 2, r: size * BULLET_RADIUS, color: line.bullet });
|
|
1183
1182
|
}
|