presenter 0.9.3 → 0.9.4
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/export.js +1 -1
- package/dist/export.js.map +1 -1
- package/dist/export.mjs +18 -24
- package/dist/export.mjs.map +1 -1
- package/dist/presenter.js +4 -4
- package/dist/presenter.js.map +1 -1
- package/dist/presenter.mjs +1107 -1114
- package/dist/presenter.mjs.map +1 -1
- package/dist/renderer/browser-canvas/utils/text/getTextLayout.d.ts +4 -11
- package/dist/renderer/browser-canvas/utils/text/getTextUnitMeasurements.d.ts +9 -0
- package/package.json +2 -2
package/dist/export.mjs
CHANGED
|
@@ -757,40 +757,34 @@ function Sa(t) {
|
|
|
757
757
|
return typeof t == "string" ? [[{ text: t }]] : t.map((n) => n.map((e) => typeof e == "string" ? { text: e } : e));
|
|
758
758
|
}
|
|
759
759
|
function Br(t) {
|
|
760
|
+
const n = Math.max(...t.map((A) => A.bottom), 0), e = Math.max(...t.map((A) => A.top), 0);
|
|
760
761
|
return {
|
|
761
|
-
bottom:
|
|
762
|
-
height:
|
|
763
|
-
lineAdvance: Math.max(...t.map((
|
|
764
|
-
top:
|
|
765
|
-
width: t.reduce((
|
|
762
|
+
bottom: n,
|
|
763
|
+
height: e + n,
|
|
764
|
+
lineAdvance: Math.max(...t.map((A) => A.lineAdvance), 0),
|
|
765
|
+
top: e,
|
|
766
|
+
width: t.reduce((A, a) => A + a.width, 0)
|
|
766
767
|
};
|
|
767
768
|
}
|
|
768
769
|
function Ia(t, n = 1) {
|
|
769
770
|
const e = t.map(Br);
|
|
770
771
|
if (e.length === 0)
|
|
771
772
|
return {
|
|
772
|
-
|
|
773
|
+
baselines: [],
|
|
773
774
|
size: xt()
|
|
774
775
|
};
|
|
775
|
-
let A =
|
|
776
|
-
const
|
|
777
|
-
for (
|
|
778
|
-
const
|
|
779
|
-
|
|
780
|
-
...o,
|
|
781
|
-
baselineY: A
|
|
782
|
-
}), a = o.lineAdvance);
|
|
776
|
+
let A = 0, a, i = 0, s = 0;
|
|
777
|
+
const c = [];
|
|
778
|
+
for (const r of e) {
|
|
779
|
+
const f = (r.lineAdvance * n - r.height) / 2, g = r.top + f;
|
|
780
|
+
a === void 0 ? A = g : A += a + g, c.push(A), i = Math.min(i, A - r.top), s = Math.max(s, A + r.bottom), a = r.bottom + f;
|
|
783
781
|
}
|
|
784
|
-
const
|
|
782
|
+
const l = -i;
|
|
785
783
|
return {
|
|
786
|
-
|
|
787
|
-
...r,
|
|
788
|
-
// Keep all returned baselines relative to the top edge of the final text block
|
|
789
|
-
baselineY: r.baselineY + l
|
|
790
|
-
})),
|
|
784
|
+
baselines: c.map((r) => r + l),
|
|
791
785
|
size: xt({
|
|
792
|
-
height:
|
|
793
|
-
width: Math.max(...
|
|
786
|
+
height: s - i,
|
|
787
|
+
width: Math.max(...e.map((r) => r.width), 0)
|
|
794
788
|
})
|
|
795
789
|
};
|
|
796
790
|
}
|
|
@@ -859,7 +853,7 @@ const Pr = ({ ctx: t, object: n, opacity: e }) => {
|
|
|
859
853
|
const { length: a } = n, i = Sa(n.text), s = Fa(n), c = Ea(i, s, t), l = Ia(c, n.lineSpacing), r = Ot(mt({ x: n.x, y: n.y }), n.anchor, l.size);
|
|
860
854
|
let o = r.origin.x, f = 0;
|
|
861
855
|
for (let g = 0; g < i.length; g++) {
|
|
862
|
-
const d = i[g], m = c[g], u = l.
|
|
856
|
+
const d = i[g], m = c[g], u = l.baselines[g];
|
|
863
857
|
if (d == null || m == null || u == null) {
|
|
864
858
|
console.error("Could not determine text units or sizes for line");
|
|
865
859
|
continue;
|
|
@@ -879,7 +873,7 @@ const Pr = ({ ctx: t, object: n, opacity: e }) => {
|
|
|
879
873
|
Ut(n.alignment);
|
|
880
874
|
break;
|
|
881
875
|
}
|
|
882
|
-
const v = r.origin.y + u
|
|
876
|
+
const v = r.origin.y + u;
|
|
883
877
|
for (let b = 0; b < d.length && !(a !== null && f >= a); b++) {
|
|
884
878
|
const x = d[b], k = m[b];
|
|
885
879
|
if (x == null || k == null) {
|