@unmade/text-renderer 1.0.0 → 1.1.1
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/__vite-browser-external-CijFC1_R.js +7 -0
- package/dist/baselines/index.d.ts +40 -0
- package/dist/ce-adapter/index.cjs +1 -1
- package/dist/ce-adapter/index.js +154 -152
- package/dist/chunk-3b4jIN3o.js +13 -0
- package/dist/constants.d.ts +5 -0
- package/dist/glyph/svg-glyph-converter.d.ts +42 -0
- package/dist/helpers/bbox.d.ts +33 -0
- package/dist/helpers/matrix.d.ts +8 -0
- package/dist/helpers/point.d.ts +17 -0
- package/dist/helpers/xml.d.ts +1 -0
- package/dist/index.d.ts +16 -249
- package/dist/index.js +1543 -1954
- package/dist/loading/createLoadedFont.d.ts +53 -0
- package/dist/loading/index.d.ts +4 -0
- package/dist/measuring/conversion.d.ts +2 -0
- package/dist/measuring/index.d.ts +28 -0
- package/dist/node/baselines/index.d.ts +40 -0
- package/dist/node/ce-adapter/ce-types.d.ts +171 -0
- package/dist/node/ce-adapter/extractTextPlacements.d.ts +11 -0
- package/dist/node/ce-adapter/index.d.ts +12 -0
- package/dist/node/ce-adapter/mapStateToRendererOptions.d.ts +13 -0
- package/dist/node/ce-adapter/types.d.ts +56 -0
- package/dist/node/constants.d.ts +5 -0
- package/dist/node/glyph/svg-glyph-converter.d.ts +42 -0
- package/dist/node/helpers/bbox.d.ts +33 -0
- package/dist/node/helpers/matrix.d.ts +8 -0
- package/dist/node/helpers/point.d.ts +17 -0
- package/dist/node/helpers/xml.d.ts +1 -0
- package/dist/node/index.d.ts +16 -249
- package/dist/node/index.js +821 -895
- package/dist/node/loading/createLoadedFont.d.ts +53 -0
- package/dist/node/loading/index.d.ts +4 -0
- package/dist/node/measuring/conversion.d.ts +2 -0
- package/dist/node/measuring/index.d.ts +28 -0
- package/dist/node/renderText.d.ts +5 -0
- package/dist/node/rendering/index.d.ts +42 -0
- package/dist/node/svg/index.d.ts +11 -0
- package/dist/node/types.d.ts +72 -0
- package/dist/renderText.d.ts +5 -0
- package/dist/rendering/index.d.ts +42 -0
- package/dist/svg/index.d.ts +11 -0
- package/dist/types.d.ts +72 -0
- package/dist/worker/baselines/index.d.ts +40 -0
- package/dist/worker/ce-adapter/ce-types.d.ts +171 -0
- package/dist/worker/ce-adapter/extractTextPlacements.d.ts +11 -0
- package/dist/worker/ce-adapter/index.d.ts +12 -0
- package/dist/worker/ce-adapter/mapStateToRendererOptions.d.ts +13 -0
- package/dist/worker/ce-adapter/types.d.ts +56 -0
- package/dist/worker/constants.d.ts +5 -0
- package/dist/worker/glyph/svg-glyph-converter.d.ts +42 -0
- package/dist/worker/helpers/bbox.d.ts +33 -0
- package/dist/worker/helpers/matrix.d.ts +8 -0
- package/dist/worker/helpers/point.d.ts +17 -0
- package/dist/worker/helpers/xml.d.ts +1 -0
- package/dist/worker/index.d.ts +16 -249
- package/dist/worker/index.js +8003 -9677
- package/dist/worker/loading/createLoadedFont.d.ts +53 -0
- package/dist/worker/loading/index.d.ts +4 -0
- package/dist/worker/measuring/conversion.d.ts +2 -0
- package/dist/worker/measuring/index.d.ts +28 -0
- package/dist/worker/renderText.d.ts +5 -0
- package/dist/worker/rendering/index.d.ts +42 -0
- package/dist/worker/svg/index.d.ts +11 -0
- package/dist/worker/types.d.ts +72 -0
- package/package.json +11 -10
- package/dist/__vite-browser-external-l0sNRNKZ.js +0 -1
package/dist/node/index.js
CHANGED
|
@@ -1,920 +1,846 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { svgPathProperties as
|
|
3
|
-
import { DOMParser as
|
|
1
|
+
import { Blob as e, Buffer as t, Face as n, Feature as r, Font as i, shape as a } from "harfbuzzjs";
|
|
2
|
+
import { svgPathProperties as o } from "svg-path-properties";
|
|
3
|
+
import { DOMParser as s } from "linkedom";
|
|
4
4
|
import "node:path";
|
|
5
|
-
import
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
5
|
+
import c from "@thednp/dommatrix";
|
|
6
|
+
//#region src/loading/createLoadedFont.ts
|
|
7
|
+
function l(e) {
|
|
8
|
+
let t = Infinity, n = Infinity, r = -Infinity, i = -Infinity, a = 0, o = 0;
|
|
9
|
+
function s(e, a) {
|
|
10
|
+
e < t && (t = e), e > r && (r = e), a < n && (n = a), a > i && (i = a);
|
|
11
|
+
}
|
|
12
|
+
function c(e, t, n) {
|
|
13
|
+
let r = e - 2 * t + n;
|
|
14
|
+
if (Math.abs(r) < 1e-10) return [];
|
|
15
|
+
let i = (e - t) / r;
|
|
16
|
+
return i > 0 && i < 1 ? [i] : [];
|
|
17
|
+
}
|
|
18
|
+
function l(e, t, n, r) {
|
|
19
|
+
let i = 1 - e;
|
|
20
|
+
return i * i * t + 2 * i * e * n + e * e * r;
|
|
21
|
+
}
|
|
22
|
+
function u(e, t, n, r) {
|
|
23
|
+
let i = t - e, a = n - t, o = r - n, s = i - 2 * a + o, c = 2 * (a - i), l = i;
|
|
24
|
+
if (Math.abs(s) < 1e-10) {
|
|
25
|
+
if (Math.abs(c) < 1e-10) return [];
|
|
26
|
+
let e = -l / c;
|
|
27
|
+
return e > 0 && e < 1 ? [e] : [];
|
|
28
|
+
}
|
|
29
|
+
let u = c * c - 4 * s * l;
|
|
30
|
+
if (u < 0) return [];
|
|
31
|
+
let d = Math.sqrt(u);
|
|
32
|
+
return [(-c + d) / (2 * s), (-c - d) / (2 * s)].filter((e) => e > 0 && e < 1);
|
|
33
|
+
}
|
|
34
|
+
function d(e, t, n, r, i) {
|
|
35
|
+
let a = 1 - e;
|
|
36
|
+
return a * a * a * t + 3 * a * a * e * n + 3 * a * e * e * r + e * e * e * i;
|
|
37
|
+
}
|
|
38
|
+
let f = /([MLCQTSAZHVmlcqtsazhv])([^MLCQTSAZHVmlcqtsazhv]*)/g, p = f.exec(e);
|
|
39
|
+
for (; p !== null;) {
|
|
40
|
+
let t = p[1].toUpperCase();
|
|
41
|
+
if (t === "Z") {
|
|
42
|
+
p = f.exec(e);
|
|
43
|
+
continue;
|
|
44
|
+
}
|
|
45
|
+
let n = p[2].trim().split(/[\s,]+/).filter(Boolean).map(Number);
|
|
46
|
+
if (t === "M" || t === "L" || t === "T") for (let e = 0; e + 1 < n.length; e += 2) a = n[e], o = n[e + 1], s(a, o);
|
|
47
|
+
else if (t === "H") for (let e of n) a = e, s(a, o);
|
|
48
|
+
else if (t === "V") for (let e of n) o = e, s(a, o);
|
|
49
|
+
else if (t === "Q") for (let e = 0; e + 3 < n.length; e += 4) {
|
|
50
|
+
let [t, r, i, u] = n.slice(e, e + 4);
|
|
51
|
+
s(i, u);
|
|
52
|
+
for (let e of c(a, t, i)) s(l(e, a, t, i), l(e, o, r, u));
|
|
53
|
+
for (let e of c(o, r, u)) s(l(e, a, t, i), l(e, o, r, u));
|
|
54
|
+
a = i, o = u;
|
|
55
|
+
}
|
|
56
|
+
else if (t === "C") for (let e = 0; e + 5 < n.length; e += 6) {
|
|
57
|
+
let [t, r, i, c, l, f] = n.slice(e, e + 6);
|
|
58
|
+
s(l, f);
|
|
59
|
+
for (let e of u(a, t, i, l)) s(d(e, a, t, i, l), d(e, o, r, c, f));
|
|
60
|
+
for (let e of u(o, r, c, f)) s(d(e, a, t, i, l), d(e, o, r, c, f));
|
|
61
|
+
a = l, o = f;
|
|
62
|
+
}
|
|
63
|
+
else for (let e = 0; e + 1 < n.length; e += 2) s(n[e], n[e + 1]);
|
|
64
|
+
p = f.exec(e);
|
|
65
|
+
}
|
|
66
|
+
return Number.isFinite(t) ? {
|
|
67
|
+
x1: t,
|
|
68
|
+
y1: n,
|
|
69
|
+
x2: r,
|
|
70
|
+
y2: i
|
|
71
|
+
} : null;
|
|
27
72
|
}
|
|
28
|
-
function
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
r[l] * t + o,
|
|
42
|
-
-r[l + 1] * n,
|
|
43
|
-
r[l + 2] * t + o,
|
|
44
|
-
-r[l + 3] * n,
|
|
45
|
-
r[l + 4] * t + o,
|
|
46
|
-
-r[l + 5] * n
|
|
47
|
-
);
|
|
48
|
-
else if (s === "Q" || s === "S")
|
|
49
|
-
for (let l = 0; l < r.length; l += 4)
|
|
50
|
-
i.push(
|
|
51
|
-
r[l] * t + o,
|
|
52
|
-
-r[l + 1] * n,
|
|
53
|
-
r[l + 2] * t + o,
|
|
54
|
-
-r[l + 3] * n
|
|
55
|
-
);
|
|
56
|
-
else if (s === "H")
|
|
57
|
-
for (let l = 0; l < r.length; l++)
|
|
58
|
-
i.push(r[l] * t + o);
|
|
59
|
-
else if (s === "V")
|
|
60
|
-
for (let l = 0; l < r.length; l++)
|
|
61
|
-
i.push(-r[l] * n);
|
|
62
|
-
else
|
|
63
|
-
return c + f;
|
|
64
|
-
return c + i.join(",");
|
|
65
|
-
}
|
|
66
|
-
);
|
|
73
|
+
function u(e, t, n, r) {
|
|
74
|
+
return e.replace(/([MLCQTSAZHVmlcqtsazhv])([^MLCQTSAZHVmlcqtsazhv]*)/g, (e, i, a) => {
|
|
75
|
+
let o = i.toUpperCase();
|
|
76
|
+
if (o === "Z") return i;
|
|
77
|
+
let s = a.trim().split(/[\s,]+/).filter(Boolean).map(Number), c = [];
|
|
78
|
+
if (o === "M" || o === "L" || o === "T") for (let e = 0; e < s.length; e += 2) c.push(s[e] * t + r, -s[e + 1] * n);
|
|
79
|
+
else if (o === "C") for (let e = 0; e < s.length; e += 6) c.push(s[e] * t + r, -s[e + 1] * n, s[e + 2] * t + r, -s[e + 3] * n, s[e + 4] * t + r, -s[e + 5] * n);
|
|
80
|
+
else if (o === "Q" || o === "S") for (let e = 0; e < s.length; e += 4) c.push(s[e] * t + r, -s[e + 1] * n, s[e + 2] * t + r, -s[e + 3] * n);
|
|
81
|
+
else if (o === "H") for (let e = 0; e < s.length; e++) c.push(s[e] * t + r);
|
|
82
|
+
else if (o === "V") for (let e = 0; e < s.length; e++) c.push(-s[e] * n);
|
|
83
|
+
else return i + a;
|
|
84
|
+
return i + c.join(",");
|
|
85
|
+
});
|
|
67
86
|
}
|
|
68
|
-
function
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
87
|
+
function d(e, n, i, o) {
|
|
88
|
+
let s = e.upem;
|
|
89
|
+
function c(e) {
|
|
90
|
+
let t = e.codePointAt(0) ?? 0, r = n.glyph(t) ?? 0, i = n.glyphExtents(r);
|
|
91
|
+
return {
|
|
92
|
+
index: r,
|
|
93
|
+
advanceWidth: n.glyphHAdvance(r),
|
|
94
|
+
name: n.glyphName(r),
|
|
95
|
+
getBoundingBox() {
|
|
96
|
+
return i ? {
|
|
97
|
+
x1: i.xBearing,
|
|
98
|
+
y1: -i.yBearing,
|
|
99
|
+
x2: i.xBearing + i.width,
|
|
100
|
+
y2: -(i.yBearing + i.height)
|
|
101
|
+
} : {
|
|
102
|
+
x1: 0,
|
|
103
|
+
y1: 0,
|
|
104
|
+
x2: 0,
|
|
105
|
+
y2: 0
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
let d = [new r("liga", 0), new r("calt", 0)];
|
|
111
|
+
function f(e, r, i, o) {
|
|
112
|
+
let c = o / s, f = new t();
|
|
113
|
+
f.addText(e), f.guessSegmentProperties(), a(n, f, d);
|
|
114
|
+
let p = f.getGlyphInfos(), m = f.getGlyphPositions(), h = 0;
|
|
115
|
+
return p.map((e, t) => {
|
|
116
|
+
let r = m[t], i = e.codepoint, a = h + r.xOffset, o = u(n.glyphToPath(i), c, c, a * c);
|
|
117
|
+
return h += r.xAdvance, {
|
|
118
|
+
getBoundingBox() {
|
|
119
|
+
return l(o) || {
|
|
120
|
+
x1: a * c,
|
|
121
|
+
y1: 0,
|
|
122
|
+
x2: a * c,
|
|
123
|
+
y2: 0
|
|
124
|
+
};
|
|
125
|
+
},
|
|
126
|
+
toPathData(e) {
|
|
127
|
+
return o;
|
|
128
|
+
}
|
|
129
|
+
};
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
function p(e, t, n, r) {
|
|
133
|
+
let i = f(e, t, n, r);
|
|
134
|
+
return {
|
|
135
|
+
getBoundingBox() {
|
|
136
|
+
if (i.length === 0) return {
|
|
137
|
+
x1: 0,
|
|
138
|
+
y1: 0,
|
|
139
|
+
x2: 0,
|
|
140
|
+
y2: 0
|
|
141
|
+
};
|
|
142
|
+
let e = i.map((e) => e.getBoundingBox());
|
|
143
|
+
return {
|
|
144
|
+
x1: Math.min(...e.map((e) => e.x1)),
|
|
145
|
+
y1: Math.min(...e.map((e) => e.y1)),
|
|
146
|
+
x2: Math.max(...e.map((e) => e.x2)),
|
|
147
|
+
y2: Math.max(...e.map((e) => e.y2))
|
|
148
|
+
};
|
|
149
|
+
},
|
|
150
|
+
toPathData(e) {
|
|
151
|
+
return i.map((e) => e.toPathData()).join("");
|
|
152
|
+
}
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
return {
|
|
156
|
+
unitsPerEm: s,
|
|
157
|
+
names: { fontFamily: i },
|
|
158
|
+
svgGlyphs: o,
|
|
159
|
+
charToGlyph: c,
|
|
160
|
+
getPath: p,
|
|
161
|
+
getPaths: f
|
|
162
|
+
};
|
|
133
163
|
}
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
164
|
+
//#endregion
|
|
165
|
+
//#region src/loading/index.ts
|
|
166
|
+
var f = /* @__PURE__ */ new Map(), p = () => f;
|
|
167
|
+
async function m(e, t) {
|
|
168
|
+
let n = new DecompressionStream(t), r = n.writable.getWriter(), i = n.readable.getReader();
|
|
169
|
+
r.write(new Uint8Array(e)), r.close();
|
|
170
|
+
let a = [];
|
|
171
|
+
for (;;) {
|
|
172
|
+
let { done: e, value: t } = await i.read();
|
|
173
|
+
if (e) break;
|
|
174
|
+
a.push(t);
|
|
175
|
+
}
|
|
176
|
+
let o = a.reduce((e, t) => e + t.length, 0), s = new Uint8Array(o), c = 0;
|
|
177
|
+
for (let e of a) s.set(e, c), c += e.length;
|
|
178
|
+
return s;
|
|
149
179
|
}
|
|
150
|
-
async function
|
|
151
|
-
|
|
180
|
+
async function h(e) {
|
|
181
|
+
return m(e, "gzip");
|
|
152
182
|
}
|
|
153
|
-
async function
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
const p = new Uint8Array(i), u = new DataView(p.buffer);
|
|
181
|
-
u.setUint32(0, n), u.setUint16(4, o), u.setUint16(6, f), u.setUint16(8, s), u.setUint16(10, r);
|
|
182
|
-
for (let h = 0; h < a.length; h++) {
|
|
183
|
-
const d = a[h], g = 12 + h * 16;
|
|
184
|
-
for (let m = 0; m < 4; m++) p[g + m] = d.tag.charCodeAt(m);
|
|
185
|
-
u.setUint32(g + 4, d.checksum), u.setUint32(g + 8, l[h]), u.setUint32(g + 12, d.origLength), p.set(c[h], l[h]);
|
|
186
|
-
}
|
|
187
|
-
return p.buffer;
|
|
183
|
+
async function g(e) {
|
|
184
|
+
let t = new DataView(e), n = t.getUint32(4), r = t.getUint16(12), i = [];
|
|
185
|
+
for (let e = 0; e < r; e++) {
|
|
186
|
+
let n = 44 + e * 20, r = String.fromCharCode(t.getUint8(n), t.getUint8(n + 1), t.getUint8(n + 2), t.getUint8(n + 3));
|
|
187
|
+
i.push({
|
|
188
|
+
tag: r,
|
|
189
|
+
offset: t.getUint32(n + 4),
|
|
190
|
+
compLength: t.getUint32(n + 8),
|
|
191
|
+
origLength: t.getUint32(n + 12),
|
|
192
|
+
checksum: t.getUint32(n + 16)
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
let a = [];
|
|
196
|
+
for (let t of i) {
|
|
197
|
+
let n = new Uint8Array(e, t.offset, t.compLength);
|
|
198
|
+
t.compLength === t.origLength ? a.push(new Uint8Array(n)) : a.push(await m(n, "deflate"));
|
|
199
|
+
}
|
|
200
|
+
let o = 2 ** Math.floor(Math.log2(r)) * 16, s = Math.floor(Math.log2(r)), c = r * 16 - o, l = 12 + r * 16, u = [];
|
|
201
|
+
for (let e = 0; e < i.length; e++) u.push(l), l += i[e].origLength + 3 & -4;
|
|
202
|
+
let d = new Uint8Array(l), f = new DataView(d.buffer);
|
|
203
|
+
f.setUint32(0, n), f.setUint16(4, r), f.setUint16(6, o), f.setUint16(8, s), f.setUint16(10, c);
|
|
204
|
+
for (let e = 0; e < i.length; e++) {
|
|
205
|
+
let t = i[e], n = 12 + e * 16;
|
|
206
|
+
for (let e = 0; e < 4; e++) d[n + e] = t.tag.charCodeAt(e);
|
|
207
|
+
f.setUint32(n + 4, t.checksum), f.setUint32(n + 8, u[e]), f.setUint32(n + 12, t.origLength), d.set(a[e], u[e]);
|
|
208
|
+
}
|
|
209
|
+
return d.buffer;
|
|
188
210
|
}
|
|
189
|
-
async function
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
211
|
+
async function _(e, t, n) {
|
|
212
|
+
let r = /* @__PURE__ */ new Map(), i = new DataView(e.buffer, e.byteOffset, e.byteLength), a = i.getUint32(2), o = i.getUint16(a), s = a;
|
|
213
|
+
for (let n = 0; n < o; n++) {
|
|
214
|
+
let o = a + 2 + n * 12, c = i.getUint16(o), l = i.getUint16(o + 2), u = i.getUint32(o + 4), d = i.getUint32(o + 8), f = s + u, p = e.slice(f, f + d);
|
|
215
|
+
p[0] === 31 && p[1] === 139 && (p = await h(p));
|
|
216
|
+
let m = new TextDecoder().decode(p);
|
|
217
|
+
for (let e = c; e <= l; e++) {
|
|
218
|
+
let n = t.glyphExtents(e), i;
|
|
219
|
+
i = n ? `${n.xBearing} ${-n.yBearing} ${n.width} ${-n.height}` : "0 0 0 0", r.set(e, {
|
|
220
|
+
svg: m,
|
|
221
|
+
viewbox: i
|
|
222
|
+
});
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
return r;
|
|
203
226
|
}
|
|
204
|
-
|
|
205
|
-
async function
|
|
206
|
-
|
|
227
|
+
var v = 2001684038;
|
|
228
|
+
async function y(e) {
|
|
229
|
+
return e.byteLength >= 4 && new DataView(e).getUint32(0) === v ? g(e) : e;
|
|
207
230
|
}
|
|
208
|
-
async function
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
`Failed to load font from ${e}: ${t.status} ${t.statusText}`
|
|
213
|
-
);
|
|
214
|
-
const n = await t.arrayBuffer();
|
|
215
|
-
return Dt(n);
|
|
231
|
+
async function b(e) {
|
|
232
|
+
let t = await fetch(e);
|
|
233
|
+
if (!t.ok) throw Error(`Failed to load font from ${e}: ${t.status} ${t.statusText}`);
|
|
234
|
+
return y(await t.arrayBuffer());
|
|
216
235
|
}
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
236
|
+
var x = async (t, r = !1) => {
|
|
237
|
+
let a = f.get(t);
|
|
238
|
+
if (a) {
|
|
239
|
+
if (r && !a.svgGlyphs) {
|
|
240
|
+
let r = new n(new e(await b(t))), o = new i(r), s = r.referenceTable("SVG ");
|
|
241
|
+
a.svgGlyphs = s ? await _(s, o, r.upem) : /* @__PURE__ */ new Map();
|
|
242
|
+
}
|
|
243
|
+
return a;
|
|
244
|
+
}
|
|
245
|
+
let o = new n(new e(await b(t))), s = new i(o), c = o.getName(1, "en") ?? "", l;
|
|
246
|
+
if (r) {
|
|
247
|
+
let e = o.referenceTable("SVG ");
|
|
248
|
+
l = e ? await _(e, s, o.upem) : /* @__PURE__ */ new Map();
|
|
249
|
+
}
|
|
250
|
+
let u = d(o, s, c, l);
|
|
251
|
+
return f.set(t, u), u;
|
|
252
|
+
}, S = .03125, C = 1.1, w = .2, T = {
|
|
253
|
+
outlineWidth: S,
|
|
254
|
+
letterSpacing: 0,
|
|
255
|
+
letterSpacingOutline: 0
|
|
256
|
+
}, E = class {
|
|
257
|
+
constructor(e, t) {
|
|
258
|
+
this.x = e, this.y = t;
|
|
259
|
+
}
|
|
260
|
+
get X() {
|
|
261
|
+
return this.x;
|
|
262
|
+
}
|
|
263
|
+
get Y() {
|
|
264
|
+
return this.y;
|
|
265
|
+
}
|
|
266
|
+
toSVGString() {
|
|
267
|
+
return `${this.x} ${this.y}`;
|
|
268
|
+
}
|
|
238
269
|
};
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
}
|
|
243
|
-
get X() {
|
|
244
|
-
return this.x;
|
|
245
|
-
}
|
|
246
|
-
get Y() {
|
|
247
|
-
return this.y;
|
|
248
|
-
}
|
|
249
|
-
toSVGString() {
|
|
250
|
-
return `${this.x} ${this.y}`;
|
|
251
|
-
}
|
|
270
|
+
function D(e, t, n = new E(0, 0)) {
|
|
271
|
+
let r = e.X - n.X, i = e.Y - n.Y, a = t / 180 * Math.PI, o = Math.cos(a), s = Math.sin(a), c = r * o - i * s, l = r * s + i * o;
|
|
272
|
+
return new E(c + n.X, l + n.Y);
|
|
252
273
|
}
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
olive: "#808000",
|
|
460
|
-
olivedrab: "#6b8e23",
|
|
461
|
-
orange: "#ffa500",
|
|
462
|
-
orangered: "#ff4500",
|
|
463
|
-
orchid: "#da70d6",
|
|
464
|
-
palegoldenrod: "#eee8aa",
|
|
465
|
-
palegreen: "#98fb98",
|
|
466
|
-
paleturquoise: "#afeeee",
|
|
467
|
-
palevioletred: "#db7093",
|
|
468
|
-
papayawhip: "#ffefd5",
|
|
469
|
-
peachpuff: "#ffdab9",
|
|
470
|
-
peru: "#cd853f",
|
|
471
|
-
pink: "#ffc0cb",
|
|
472
|
-
plum: "#dda0dd",
|
|
473
|
-
powderblue: "#b0e0e6",
|
|
474
|
-
purple: "#800080",
|
|
475
|
-
rebeccapurple: "#663399",
|
|
476
|
-
red: "#ff0000",
|
|
477
|
-
rosybrown: "#bc8f8f",
|
|
478
|
-
royalblue: "#4169e1",
|
|
479
|
-
saddlebrown: "#8b4513",
|
|
480
|
-
salmon: "#fa8072",
|
|
481
|
-
sandybrown: "#f4a460",
|
|
482
|
-
seagreen: "#2e8b57",
|
|
483
|
-
seashell: "#fff5ee",
|
|
484
|
-
sienna: "#a0522d",
|
|
485
|
-
silver: "#c0c0c0",
|
|
486
|
-
skyblue: "#87ceeb",
|
|
487
|
-
slateblue: "#6a5acd",
|
|
488
|
-
slategray: "#708090",
|
|
489
|
-
slategrey: "#708090",
|
|
490
|
-
snow: "#fffafa",
|
|
491
|
-
springgreen: "#00ff7f",
|
|
492
|
-
steelblue: "#4682b4",
|
|
493
|
-
tan: "#d2b48c",
|
|
494
|
-
teal: "#008080",
|
|
495
|
-
thistle: "#d8bfd8",
|
|
496
|
-
tomato: "#ff6347",
|
|
497
|
-
turquoise: "#40e0d0",
|
|
498
|
-
violet: "#ee82ee",
|
|
499
|
-
wheat: "#f5deb3",
|
|
500
|
-
white: "#ffffff",
|
|
501
|
-
whitesmoke: "#f5f5f5",
|
|
502
|
-
yellow: "#ffff00",
|
|
503
|
-
yellowgreen: "#9acd32"
|
|
504
|
-
}, Yt = (e) => {
|
|
505
|
-
let t = Array.from(e), n = !1;
|
|
506
|
-
return t[0] === "#" && (t.shift(), n = !0), t.length === 3 && (t = t.map((o) => `${o}${o}`)), `${n ? "#" : ""}${t.join("").toLowerCase()}`;
|
|
507
|
-
}, R = (e) => {
|
|
508
|
-
const t = typeof e == "string" ? Number.parseInt(e, 10) : e;
|
|
509
|
-
return Math.max(0, Math.min(255, Math.round(t))).toString(16).padStart(2, "0");
|
|
510
|
-
}, lt = (...e) => {
|
|
511
|
-
const [t, n, o] = Array.isArray(e[0]) ? e[0] : e;
|
|
512
|
-
return `#${R(t)}${R(n)}${R(o)}`;
|
|
513
|
-
}, Jt = (e, t, n) => {
|
|
514
|
-
if (t === 0) {
|
|
515
|
-
const l = Math.round(n * 255);
|
|
516
|
-
return [l, l, l];
|
|
517
|
-
}
|
|
518
|
-
const o = (e % 360 + 360) % 360, a = (1 - Math.abs(2 * n - 1)) * t, c = a * (1 - Math.abs(o / 60 % 2 - 1)), f = n - a / 2;
|
|
519
|
-
let s = 0, r = 0, i = 0;
|
|
520
|
-
return o < 60 ? (s = a, r = c, i = 0) : o < 120 ? (s = c, r = a, i = 0) : o < 180 ? (s = 0, r = a, i = c) : o < 240 ? (s = 0, r = c, i = a) : o < 300 ? (s = c, r = 0, i = a) : (s = a, r = 0, i = c), [
|
|
521
|
-
Math.round((s + f) * 255),
|
|
522
|
-
Math.round((r + f) * 255),
|
|
523
|
-
Math.round((i + f) * 255)
|
|
524
|
-
];
|
|
525
|
-
}, Kt = (e) => /^#?([0-9a-f]{3}|[0-9a-f]{6})$/i.test(e), Z = (e) => {
|
|
526
|
-
const t = e.trim().toLowerCase();
|
|
527
|
-
if (t.startsWith("#") || /^[0-9a-f]{3}([0-9a-f]{3})?$/.test(t))
|
|
528
|
-
return Kt(t) ? Yt(t) : void 0;
|
|
529
|
-
if (t.startsWith("rgb")) {
|
|
530
|
-
const o = t.match(
|
|
531
|
-
/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*[\d.]+\s*)?\)/
|
|
532
|
-
);
|
|
533
|
-
return o ? lt(
|
|
534
|
-
Number.parseInt(o[1], 10),
|
|
535
|
-
Number.parseInt(o[2], 10),
|
|
536
|
-
Number.parseInt(o[3], 10)
|
|
537
|
-
) : void 0;
|
|
538
|
-
}
|
|
539
|
-
if (t.startsWith("hsl")) {
|
|
540
|
-
const o = t.match(
|
|
541
|
-
/hsla?\(\s*(\d+)\s*,\s*([\d.]+)%\s*,\s*([\d.]+)%\s*(?:,\s*[\d.]+\s*)?\)/
|
|
542
|
-
);
|
|
543
|
-
if (!o) return;
|
|
544
|
-
const a = Number.parseInt(o[1], 10), c = Number.parseFloat(o[2]) / 100, f = Number.parseFloat(o[3]) / 100, [s, r, i] = Jt(a, c, f);
|
|
545
|
-
return lt(s, r, i);
|
|
546
|
-
}
|
|
547
|
-
const n = Qt[t];
|
|
548
|
-
if (n) return n;
|
|
549
|
-
}, L = {
|
|
550
|
-
circle: "circle",
|
|
551
|
-
ellipse: "ellipse",
|
|
552
|
-
rect: "rect",
|
|
553
|
-
line: "line",
|
|
554
|
-
path: "path",
|
|
555
|
-
polygon: "polygon",
|
|
556
|
-
polyline: "polyline",
|
|
557
|
-
stop: "stop"
|
|
558
|
-
}, O = {
|
|
559
|
-
fill: "fill",
|
|
560
|
-
stroke: "stroke"
|
|
561
|
-
}, te = {
|
|
562
|
-
tiling: [
|
|
563
|
-
L.circle,
|
|
564
|
-
L.ellipse,
|
|
565
|
-
L.rect,
|
|
566
|
-
L.line,
|
|
567
|
-
L.path,
|
|
568
|
-
L.polygon,
|
|
569
|
-
L.polyline,
|
|
570
|
-
L.stop,
|
|
571
|
-
`[${O.fill}]`,
|
|
572
|
-
`[${O.stroke}]`
|
|
573
|
-
]
|
|
574
|
-
}, ee = (e) => Array.from(
|
|
575
|
-
e.querySelectorAll(
|
|
576
|
-
te.tiling.map((t) => `*:not(clipPath) > ${t}`).join(", ")
|
|
577
|
-
)
|
|
578
|
-
), ne = (e) => {
|
|
579
|
-
const t = e.getAttribute(O.stroke);
|
|
580
|
-
return t === "none" || !t ? !1 : t;
|
|
581
|
-
}, j = (e) => {
|
|
582
|
-
if (!(e === "none" || e === "transparent" || e.startsWith("url(")))
|
|
583
|
-
return Z(e);
|
|
584
|
-
}, oe = (e) => {
|
|
585
|
-
const t = ee(e).reduce(
|
|
586
|
-
(n, o) => {
|
|
587
|
-
const a = o.getAttribute("stop-color"), c = o.getAttribute(O.fill) || "#000", f = ne(o);
|
|
588
|
-
if (!a) {
|
|
589
|
-
const s = j(c);
|
|
590
|
-
s && n.add(s);
|
|
591
|
-
}
|
|
592
|
-
if (a) {
|
|
593
|
-
const s = j(a);
|
|
594
|
-
s && n.add(s);
|
|
595
|
-
}
|
|
596
|
-
if (f) {
|
|
597
|
-
const s = j(f);
|
|
598
|
-
s && n.add(s);
|
|
599
|
-
}
|
|
600
|
-
return n;
|
|
601
|
-
},
|
|
602
|
-
/* @__PURE__ */ new Set()
|
|
603
|
-
);
|
|
604
|
-
return Array.from(t);
|
|
274
|
+
//#endregion
|
|
275
|
+
//#region src/baselines/index.ts
|
|
276
|
+
var O = (e) => e === void 0 || e === "flat" ? { type: "flat" } : e === "curved" ? { type: "curved" } : e, k = (e) => {
|
|
277
|
+
if (!e || !e.trim()) throw Error("Custom baseline path must be a non-empty SVG path string");
|
|
278
|
+
if (!e.trim().startsWith("M")) throw Error("Custom baseline path must start with an M (moveto) command");
|
|
279
|
+
}, A = ({ boxDimensions: e, totalTextHeight: t, baseline: n, lineHeight: r, verticalAlignment: i = "centre", lineNumber: a = 0 }) => {
|
|
280
|
+
let { width: o, height: s } = e, c = r - n, l = n;
|
|
281
|
+
switch (i) {
|
|
282
|
+
case "centre":
|
|
283
|
+
l = (s - t) / 2 + r - c;
|
|
284
|
+
break;
|
|
285
|
+
case "bottom":
|
|
286
|
+
l = s - t + r - c;
|
|
287
|
+
break;
|
|
288
|
+
}
|
|
289
|
+
return l += r * C * a, `M 0 ${l} L ${o} ${l}`;
|
|
290
|
+
}, j = ({ boxDimensions: e, baseline: t, textHeight: n, verticalAlignment: r }) => {
|
|
291
|
+
let { width: i, height: a } = e, o = n * w, s = n + o, c = r === "top" ? 0 : a / 2 - s / 2, l = t + c, u = l + o;
|
|
292
|
+
if (r !== "top" && (u > a || l - n < 0)) return j({
|
|
293
|
+
boxDimensions: e,
|
|
294
|
+
baseline: t,
|
|
295
|
+
textHeight: n,
|
|
296
|
+
verticalAlignment: "top"
|
|
297
|
+
});
|
|
298
|
+
let d = n / 4, f = new E(d, u), p = new E(i / 2, l), m = new E(i - d, u), h = i * .2, g = new E(h, t + c), _ = new E(i - h, t + c);
|
|
299
|
+
return `${`M ${f.toSVGString()}`} ${`Q ${g.toSVGString()} ${p.toSVGString()}`} ${`Q ${_.toSVGString()} ${m.toSVGString()}`}`;
|
|
300
|
+
}, M = (e) => {
|
|
301
|
+
for (let t of [
|
|
302
|
+
"I",
|
|
303
|
+
"l",
|
|
304
|
+
"1"
|
|
305
|
+
]) {
|
|
306
|
+
let n = e.charToGlyph(t);
|
|
307
|
+
if (n && n.name !== ".notdef") return t;
|
|
308
|
+
}
|
|
309
|
+
return console.error("No standard character found for fixed height calculation. Using \"I\" as default."), "I";
|
|
310
|
+
}, N = 100, P = ({ font: e, boxDimensions: t, physicalSize: n, spacing: r = T }) => {
|
|
311
|
+
let i = n;
|
|
312
|
+
if (i[1] !== t.physicalUnits) throw Error(`Mismatched units between physicalFontSize (${i[1]}) and boxDimensions (${t.physicalUnits})`);
|
|
313
|
+
let { outlineWidth: a } = r, o = M(e), s = e.getPath(o, 0, 0, N).getBoundingBox(), c = s.y2 - s.y1;
|
|
314
|
+
if (a > 0) {
|
|
315
|
+
let e = N * a;
|
|
316
|
+
c += e * 2;
|
|
317
|
+
}
|
|
318
|
+
let l = c / t.height * t.physicalHeight;
|
|
319
|
+
return N * (i[0] / l);
|
|
320
|
+
}, F = ({ font: e, text: t, fontSize: n, spacing: r = T }) => {
|
|
321
|
+
let { outlineWidth: i, letterSpacing: a, letterSpacingOutline: o } = r, s = e.getPath(t, 0, 0, n).getBoundingBox(), c = i ? n * i * 2 : 0, l = i > 0 ? o : a, u = t.length > 1 ? l * n * (t.length - 1) : 0;
|
|
322
|
+
return {
|
|
323
|
+
width: s.x2 - s.x1 + c + u,
|
|
324
|
+
height: s.y2 - s.y1 + c,
|
|
325
|
+
baseline: s.y1 * -1 + c / 2
|
|
326
|
+
};
|
|
327
|
+
}, I = s, ee = c, te = new I().parseFromString("<svg></svg>", "image/svg+xml");
|
|
328
|
+
te.readyState = "complete";
|
|
329
|
+
//#endregion
|
|
330
|
+
//#region ../svg-helpers/dist/colours/named-colours.mjs
|
|
331
|
+
var ne = {
|
|
332
|
+
aliceblue: "#f0f8ff",
|
|
333
|
+
antiquewhite: "#faebd7",
|
|
334
|
+
aqua: "#00ffff",
|
|
335
|
+
aquamarine: "#7fffd4",
|
|
336
|
+
azure: "#f0ffff",
|
|
337
|
+
beige: "#f5f5dc",
|
|
338
|
+
bisque: "#ffe4c4",
|
|
339
|
+
black: "#000000",
|
|
340
|
+
blanchedalmond: "#ffebcd",
|
|
341
|
+
blue: "#0000ff",
|
|
342
|
+
blueviolet: "#8a2be2",
|
|
343
|
+
brown: "#a52a2a",
|
|
344
|
+
burlywood: "#deb887",
|
|
345
|
+
cadetblue: "#5f9ea0",
|
|
346
|
+
chartreuse: "#7fff00",
|
|
347
|
+
chocolate: "#d2691e",
|
|
348
|
+
coral: "#ff7f50",
|
|
349
|
+
cornflowerblue: "#6495ed",
|
|
350
|
+
cornsilk: "#fff8dc",
|
|
351
|
+
crimson: "#dc143c",
|
|
352
|
+
cyan: "#00ffff",
|
|
353
|
+
darkblue: "#00008b",
|
|
354
|
+
darkcyan: "#008b8b",
|
|
355
|
+
darkgoldenrod: "#b8860b",
|
|
356
|
+
darkgray: "#a9a9a9",
|
|
357
|
+
darkgreen: "#006400",
|
|
358
|
+
darkgrey: "#a9a9a9",
|
|
359
|
+
darkkhaki: "#bdb76b",
|
|
360
|
+
darkmagenta: "#8b008b",
|
|
361
|
+
darkolivegreen: "#556b2f",
|
|
362
|
+
darkorange: "#ff8c00",
|
|
363
|
+
darkorchid: "#9932cc",
|
|
364
|
+
darkred: "#8b0000",
|
|
365
|
+
darksalmon: "#e9967a",
|
|
366
|
+
darkseagreen: "#8fbc8f",
|
|
367
|
+
darkslateblue: "#483d8b",
|
|
368
|
+
darkslategray: "#2f4f4f",
|
|
369
|
+
darkslategrey: "#2f4f4f",
|
|
370
|
+
darkturquoise: "#00ced1",
|
|
371
|
+
darkviolet: "#9400d3",
|
|
372
|
+
deeppink: "#ff1493",
|
|
373
|
+
deepskyblue: "#00bfff",
|
|
374
|
+
dimgray: "#696969",
|
|
375
|
+
dimgrey: "#696969",
|
|
376
|
+
dodgerblue: "#1e90ff",
|
|
377
|
+
firebrick: "#b22222",
|
|
378
|
+
floralwhite: "#fffaf0",
|
|
379
|
+
forestgreen: "#228b22",
|
|
380
|
+
fuchsia: "#ff00ff",
|
|
381
|
+
gainsboro: "#dcdcdc",
|
|
382
|
+
ghostwhite: "#f8f8ff",
|
|
383
|
+
gold: "#ffd700",
|
|
384
|
+
goldenrod: "#daa520",
|
|
385
|
+
gray: "#808080",
|
|
386
|
+
green: "#008000",
|
|
387
|
+
greenyellow: "#adff2f",
|
|
388
|
+
grey: "#808080",
|
|
389
|
+
honeydew: "#f0fff0",
|
|
390
|
+
hotpink: "#ff69b4",
|
|
391
|
+
indianred: "#cd5c5c",
|
|
392
|
+
indigo: "#4b0082",
|
|
393
|
+
ivory: "#fffff0",
|
|
394
|
+
khaki: "#f0e68c",
|
|
395
|
+
lavender: "#e6e6fa",
|
|
396
|
+
lavenderblush: "#fff0f5",
|
|
397
|
+
lawngreen: "#7cfc00",
|
|
398
|
+
lemonchiffon: "#fffacd",
|
|
399
|
+
lightblue: "#add8e6",
|
|
400
|
+
lightcoral: "#f08080",
|
|
401
|
+
lightcyan: "#e0ffff",
|
|
402
|
+
lightgoldenrodyellow: "#fafad2",
|
|
403
|
+
lightgray: "#d3d3d3",
|
|
404
|
+
lightgreen: "#90ee90",
|
|
405
|
+
lightgrey: "#d3d3d3",
|
|
406
|
+
lightpink: "#ffb6c1",
|
|
407
|
+
lightsalmon: "#ffa07a",
|
|
408
|
+
lightseagreen: "#20b2aa",
|
|
409
|
+
lightskyblue: "#87cefa",
|
|
410
|
+
lightslategray: "#778899",
|
|
411
|
+
lightslategrey: "#778899",
|
|
412
|
+
lightsteelblue: "#b0c4de",
|
|
413
|
+
lightyellow: "#ffffe0",
|
|
414
|
+
lime: "#00ff00",
|
|
415
|
+
limegreen: "#32cd32",
|
|
416
|
+
linen: "#faf0e6",
|
|
417
|
+
magenta: "#ff00ff",
|
|
418
|
+
maroon: "#800000",
|
|
419
|
+
mediumaquamarine: "#66cdaa",
|
|
420
|
+
mediumblue: "#0000cd",
|
|
421
|
+
mediumorchid: "#ba55d3",
|
|
422
|
+
mediumpurple: "#9370db",
|
|
423
|
+
mediumseagreen: "#3cb371",
|
|
424
|
+
mediumslateblue: "#7b68ee",
|
|
425
|
+
mediumspringgreen: "#00fa9a",
|
|
426
|
+
mediumturquoise: "#48d1cc",
|
|
427
|
+
mediumvioletred: "#c71585",
|
|
428
|
+
midnightblue: "#191970",
|
|
429
|
+
mintcream: "#f5fffa",
|
|
430
|
+
mistyrose: "#ffe4e1",
|
|
431
|
+
moccasin: "#ffe4b5",
|
|
432
|
+
navajowhite: "#ffdead",
|
|
433
|
+
navy: "#000080",
|
|
434
|
+
oldlace: "#fdf5e6",
|
|
435
|
+
olive: "#808000",
|
|
436
|
+
olivedrab: "#6b8e23",
|
|
437
|
+
orange: "#ffa500",
|
|
438
|
+
orangered: "#ff4500",
|
|
439
|
+
orchid: "#da70d6",
|
|
440
|
+
palegoldenrod: "#eee8aa",
|
|
441
|
+
palegreen: "#98fb98",
|
|
442
|
+
paleturquoise: "#afeeee",
|
|
443
|
+
palevioletred: "#db7093",
|
|
444
|
+
papayawhip: "#ffefd5",
|
|
445
|
+
peachpuff: "#ffdab9",
|
|
446
|
+
peru: "#cd853f",
|
|
447
|
+
pink: "#ffc0cb",
|
|
448
|
+
plum: "#dda0dd",
|
|
449
|
+
powderblue: "#b0e0e6",
|
|
450
|
+
purple: "#800080",
|
|
451
|
+
rebeccapurple: "#663399",
|
|
452
|
+
red: "#ff0000",
|
|
453
|
+
rosybrown: "#bc8f8f",
|
|
454
|
+
royalblue: "#4169e1",
|
|
455
|
+
saddlebrown: "#8b4513",
|
|
456
|
+
salmon: "#fa8072",
|
|
457
|
+
sandybrown: "#f4a460",
|
|
458
|
+
seagreen: "#2e8b57",
|
|
459
|
+
seashell: "#fff5ee",
|
|
460
|
+
sienna: "#a0522d",
|
|
461
|
+
silver: "#c0c0c0",
|
|
462
|
+
skyblue: "#87ceeb",
|
|
463
|
+
slateblue: "#6a5acd",
|
|
464
|
+
slategray: "#708090",
|
|
465
|
+
slategrey: "#708090",
|
|
466
|
+
snow: "#fffafa",
|
|
467
|
+
springgreen: "#00ff7f",
|
|
468
|
+
steelblue: "#4682b4",
|
|
469
|
+
tan: "#d2b48c",
|
|
470
|
+
teal: "#008080",
|
|
471
|
+
thistle: "#d8bfd8",
|
|
472
|
+
tomato: "#ff6347",
|
|
473
|
+
turquoise: "#40e0d0",
|
|
474
|
+
violet: "#ee82ee",
|
|
475
|
+
wheat: "#f5deb3",
|
|
476
|
+
white: "#ffffff",
|
|
477
|
+
whitesmoke: "#f5f5f5",
|
|
478
|
+
yellow: "#ffff00",
|
|
479
|
+
yellowgreen: "#9acd32"
|
|
605
480
|
}, re = (e) => {
|
|
606
|
-
|
|
607
|
-
|
|
481
|
+
let t = Array.from(e), n = !1;
|
|
482
|
+
return t[0] === "#" && (t.shift(), n = !0), t.length === 3 && (t = t.map((e) => `${e}${e}`)), `${n ? "#" : ""}${t.join("").toLowerCase()}`;
|
|
483
|
+
}, L = (e) => Math.max(0, Math.min(255, Math.round(typeof e == "string" ? Number.parseInt(e, 10) : e))).toString(16).padStart(2, "0"), R = (...e) => {
|
|
484
|
+
let [t, n, r] = Array.isArray(e[0]) ? e[0] : e;
|
|
485
|
+
return `#${L(t)}${L(n)}${L(r)}`;
|
|
486
|
+
}, ie = (e, t, n) => {
|
|
487
|
+
if (t === 0) {
|
|
488
|
+
let e = Math.round(n * 255);
|
|
489
|
+
return [
|
|
490
|
+
e,
|
|
491
|
+
e,
|
|
492
|
+
e
|
|
493
|
+
];
|
|
494
|
+
}
|
|
495
|
+
let r = (e % 360 + 360) % 360, i = (1 - Math.abs(2 * n - 1)) * t, a = i * (1 - Math.abs(r / 60 % 2 - 1)), o = n - i / 2, s = 0, c = 0, l = 0;
|
|
496
|
+
return r < 60 ? (s = i, c = a, l = 0) : r < 120 ? (s = a, c = i, l = 0) : r < 180 ? (s = 0, c = i, l = a) : r < 240 ? (s = 0, c = a, l = i) : r < 300 ? (s = a, c = 0, l = i) : (s = i, c = 0, l = a), [
|
|
497
|
+
Math.round((s + o) * 255),
|
|
498
|
+
Math.round((c + o) * 255),
|
|
499
|
+
Math.round((l + o) * 255)
|
|
500
|
+
];
|
|
501
|
+
}, ae = (e) => /^#?([0-9a-f]{3}|[0-9a-f]{6})$/i.test(e), z = (e) => {
|
|
502
|
+
let t = e.trim().toLowerCase();
|
|
503
|
+
if (t.startsWith("#") || /^[0-9a-f]{3}([0-9a-f]{3})?$/.test(t)) return ae(t) ? re(t) : void 0;
|
|
504
|
+
if (t.startsWith("rgb")) {
|
|
505
|
+
let e = t.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*[\d.]+\s*)?\)/);
|
|
506
|
+
return e ? R(Number.parseInt(e[1], 10), Number.parseInt(e[2], 10), Number.parseInt(e[3], 10)) : void 0;
|
|
507
|
+
}
|
|
508
|
+
if (t.startsWith("hsl")) {
|
|
509
|
+
let e = t.match(/hsla?\(\s*(\d+)\s*,\s*([\d.]+)%\s*,\s*([\d.]+)%\s*(?:,\s*[\d.]+\s*)?\)/);
|
|
510
|
+
if (!e) return;
|
|
511
|
+
let [n, r, i] = ie(Number.parseInt(e[1], 10), Number.parseFloat(e[2]) / 100, Number.parseFloat(e[3]) / 100);
|
|
512
|
+
return R(n, r, i);
|
|
513
|
+
}
|
|
514
|
+
let n = ne[t];
|
|
515
|
+
if (n) return n;
|
|
516
|
+
}, B = {
|
|
517
|
+
svg: "svg",
|
|
518
|
+
circle: "circle",
|
|
519
|
+
desc: "desc",
|
|
520
|
+
ellipse: "ellipse",
|
|
521
|
+
rect: "rect",
|
|
522
|
+
line: "line",
|
|
523
|
+
path: "path",
|
|
524
|
+
polygon: "polygon",
|
|
525
|
+
polyline: "polyline",
|
|
526
|
+
stop: "stop"
|
|
527
|
+
}, V = {
|
|
528
|
+
fill: "fill",
|
|
529
|
+
stroke: "stroke"
|
|
530
|
+
}, oe = {
|
|
531
|
+
tiling: [
|
|
532
|
+
B.circle,
|
|
533
|
+
B.ellipse,
|
|
534
|
+
B.rect,
|
|
535
|
+
B.line,
|
|
536
|
+
B.path,
|
|
537
|
+
B.polygon,
|
|
538
|
+
B.polyline,
|
|
539
|
+
B.stop,
|
|
540
|
+
`[${V.fill}]`,
|
|
541
|
+
`[${V.stroke}]`
|
|
542
|
+
],
|
|
543
|
+
nonTiling: [
|
|
544
|
+
B.circle,
|
|
545
|
+
B.desc,
|
|
546
|
+
B.ellipse,
|
|
547
|
+
B.rect,
|
|
548
|
+
B.line,
|
|
549
|
+
B.path,
|
|
550
|
+
B.polygon,
|
|
551
|
+
B.polyline,
|
|
552
|
+
B.stop,
|
|
553
|
+
`[${V.fill}]`,
|
|
554
|
+
`[${V.stroke}]`
|
|
555
|
+
]
|
|
556
|
+
}, se = (e) => Array.from(e.querySelectorAll(oe.tiling.map((e) => `*:not(clipPath) > ${e}`).join(", "))), H = (e) => {
|
|
557
|
+
let t = e.getAttribute(V.stroke);
|
|
558
|
+
return t === "none" || !t ? !1 : t;
|
|
559
|
+
}, U = (e) => {
|
|
560
|
+
if (!(e === "none" || e === "transparent" || e.startsWith("url("))) return z(e);
|
|
561
|
+
}, W = (e) => {
|
|
562
|
+
let t = se(e).reduce((e, t) => {
|
|
563
|
+
let n = t.getAttribute("stop-color"), r = t.getAttribute(V.fill) || "#000", i = H(t);
|
|
564
|
+
if (r && !n) {
|
|
565
|
+
let t = U(r);
|
|
566
|
+
t && e.add(t);
|
|
567
|
+
}
|
|
568
|
+
if (n) {
|
|
569
|
+
let t = U(n);
|
|
570
|
+
t && e.add(t);
|
|
571
|
+
}
|
|
572
|
+
if (i) {
|
|
573
|
+
let t = U(i);
|
|
574
|
+
t && e.add(t);
|
|
575
|
+
}
|
|
576
|
+
return e;
|
|
577
|
+
}, /* @__PURE__ */ new Set());
|
|
578
|
+
return Array.from(t);
|
|
579
|
+
}, G = (e) => {
|
|
580
|
+
let t = new I().parseFromString(e, "image/svg+xml").querySelector("svg");
|
|
581
|
+
return t ? W(t) : [];
|
|
608
582
|
};
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
583
|
+
//#endregion
|
|
584
|
+
//#region src/glyph/svg-glyph-converter.ts
|
|
585
|
+
function K(e) {
|
|
586
|
+
let t = e.trim(), n = t.startsWith("<svg") || t.startsWith("<?xml"), r = n ? t : `<svg>${t}</svg>`;
|
|
587
|
+
return {
|
|
588
|
+
doc: new I().parseFromString(r, "image/svg+xml"),
|
|
589
|
+
wasWrapped: !n
|
|
590
|
+
};
|
|
612
591
|
}
|
|
613
|
-
function
|
|
614
|
-
|
|
615
|
-
|
|
592
|
+
function q(e, t) {
|
|
593
|
+
let n = e.querySelector("svg");
|
|
594
|
+
return n ? t ? n.innerHTML : n.outerHTML : "";
|
|
616
595
|
}
|
|
617
|
-
function
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
for (const a of re(o.svg))
|
|
624
|
-
n.add(a);
|
|
625
|
-
return Array.from(n);
|
|
596
|
+
function ce(e) {
|
|
597
|
+
let { svgGlyphs: t } = e;
|
|
598
|
+
if (!t || t.size === 0) return [];
|
|
599
|
+
let n = /* @__PURE__ */ new Set();
|
|
600
|
+
for (let [, e] of t) for (let t of G(e.svg)) n.add(t);
|
|
601
|
+
return Array.from(n);
|
|
626
602
|
}
|
|
627
|
-
function
|
|
628
|
-
|
|
603
|
+
function le(e) {
|
|
604
|
+
return !!e && e !== "none" && e !== "transparent" && !e.startsWith("url(");
|
|
629
605
|
}
|
|
630
|
-
function
|
|
631
|
-
|
|
632
|
-
|
|
606
|
+
function ue(e) {
|
|
607
|
+
let t = new I().parseFromString(e, "image/svg+xml").querySelector("svg");
|
|
608
|
+
return t ? t.innerHTML.trim() : "";
|
|
633
609
|
}
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
610
|
+
var de = [
|
|
611
|
+
"fill",
|
|
612
|
+
"stroke",
|
|
613
|
+
"clip-path",
|
|
614
|
+
"mask",
|
|
615
|
+
"filter"
|
|
616
|
+
];
|
|
617
|
+
function fe(e, t) {
|
|
618
|
+
let { doc: n, wasWrapped: r } = K(e), i = /* @__PURE__ */ new Map();
|
|
619
|
+
for (let e of n.querySelectorAll("[id]")) {
|
|
620
|
+
let n = e.getAttribute("id");
|
|
621
|
+
if (!n) continue;
|
|
622
|
+
let r = `${t}-${n}`;
|
|
623
|
+
i.set(n, r), e.setAttribute("id", r);
|
|
624
|
+
}
|
|
625
|
+
if (i.size === 0) return e;
|
|
626
|
+
for (let e of de) for (let t of n.querySelectorAll(`[${e}]`)) {
|
|
627
|
+
let n = t.getAttribute(e);
|
|
628
|
+
if (n) {
|
|
629
|
+
let r = n.replace(/url\(#([^)]+)\)/g, (e, t) => {
|
|
630
|
+
let n = i.get(t);
|
|
631
|
+
return n ? `url(#${n})` : `url(#${t})`;
|
|
632
|
+
});
|
|
633
|
+
r !== n && t.setAttribute(e, r);
|
|
634
|
+
}
|
|
635
|
+
}
|
|
636
|
+
for (let e of n.querySelectorAll("[href], [xlink\\:href]")) for (let t of ["href", "xlink:href"]) {
|
|
637
|
+
let n = e.getAttribute(t);
|
|
638
|
+
if (n?.startsWith("#")) {
|
|
639
|
+
let r = n.slice(1), a = i.get(r);
|
|
640
|
+
a && e.setAttribute(t, `#${a}`);
|
|
641
|
+
}
|
|
642
|
+
}
|
|
643
|
+
return q(n, r);
|
|
665
644
|
}
|
|
666
|
-
|
|
645
|
+
var pe = [
|
|
646
|
+
"fill",
|
|
647
|
+
"stroke",
|
|
648
|
+
"stop-color"
|
|
649
|
+
], me = [
|
|
650
|
+
"path",
|
|
651
|
+
"rect",
|
|
652
|
+
"circle",
|
|
653
|
+
"ellipse",
|
|
654
|
+
"polygon",
|
|
655
|
+
"polyline",
|
|
656
|
+
"text"
|
|
657
|
+
];
|
|
667
658
|
function he(e, t) {
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
s.setAttribute("fill", c.hex);
|
|
683
|
-
}
|
|
684
|
-
return bt(n, o);
|
|
659
|
+
let { doc: n, wasWrapped: r } = K(e), i = {};
|
|
660
|
+
for (let [e, n] of Object.entries(t)) i[z(e) ?? e.toLowerCase()] = n;
|
|
661
|
+
for (let e of pe) for (let t of n.querySelectorAll(`[${e}]`)) {
|
|
662
|
+
let n = t.getAttribute(e);
|
|
663
|
+
if (!n || !le(n)) continue;
|
|
664
|
+
let r = z(n), a = r ? i[r] : void 0;
|
|
665
|
+
a && t.setAttribute(e, a.hex);
|
|
666
|
+
}
|
|
667
|
+
let a = i["#000000"];
|
|
668
|
+
if (a) {
|
|
669
|
+
let e = me.map((e) => `${e}:not([fill])`).join(", ");
|
|
670
|
+
for (let t of n.querySelectorAll(e)) t.setAttribute("fill", a.hex);
|
|
671
|
+
}
|
|
672
|
+
return q(n, r);
|
|
685
673
|
}
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
674
|
+
//#endregion
|
|
675
|
+
//#region src/helpers/matrix.ts
|
|
676
|
+
var ge = (e = [
|
|
677
|
+
1,
|
|
678
|
+
0,
|
|
679
|
+
0,
|
|
680
|
+
1,
|
|
681
|
+
0,
|
|
682
|
+
0
|
|
683
|
+
]) => {
|
|
684
|
+
let t = new ee(`matrix(${e.join(",")})`);
|
|
685
|
+
if (!t) throw Error("Your browser does not support matrices");
|
|
686
|
+
return t;
|
|
691
687
|
};
|
|
692
|
-
|
|
693
|
-
|
|
688
|
+
//#endregion
|
|
689
|
+
//#region src/helpers/xml.ts
|
|
690
|
+
function _e(e) {
|
|
691
|
+
return e.replace(/&/g, "&").replace(/"/g, """).replace(/'/g, "'").replace(/</g, "<").replace(/>/g, ">");
|
|
694
692
|
}
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
switch (w.type) {
|
|
847
|
-
case "custom":
|
|
848
|
-
Ht(w.path), x = w.path;
|
|
849
|
-
break;
|
|
850
|
-
case "curved": {
|
|
851
|
-
const C = ct({
|
|
852
|
-
font: n,
|
|
853
|
-
text: yt(n),
|
|
854
|
-
fontSize: $,
|
|
855
|
-
spacing: f
|
|
856
|
-
});
|
|
857
|
-
x = mt({
|
|
858
|
-
boxDimensions: c,
|
|
859
|
-
baseline: C.baseline,
|
|
860
|
-
textHeight: C.height,
|
|
861
|
-
verticalAlignment: s
|
|
862
|
-
});
|
|
863
|
-
break;
|
|
864
|
-
}
|
|
865
|
-
case "flat":
|
|
866
|
-
x = zt({
|
|
867
|
-
boxDimensions: c,
|
|
868
|
-
totalTextHeight: U,
|
|
869
|
-
baseline: A,
|
|
870
|
-
lineHeight: S,
|
|
871
|
-
verticalAlignment: s,
|
|
872
|
-
lineNumber: y
|
|
873
|
-
});
|
|
874
|
-
break;
|
|
875
|
-
}
|
|
876
|
-
const B = ue({
|
|
877
|
-
font: n,
|
|
878
|
-
baselinePath: x,
|
|
879
|
-
text: b[y],
|
|
880
|
-
fontSize: $,
|
|
881
|
-
spacing: f,
|
|
882
|
-
horizontalAlignment: i,
|
|
883
|
-
colourMap: u
|
|
884
|
-
});
|
|
885
|
-
v.push(...B);
|
|
886
|
-
}
|
|
887
|
-
return pe({
|
|
888
|
-
boxDimensions: c,
|
|
889
|
-
paths: v,
|
|
890
|
-
spacing: f,
|
|
891
|
-
fontSize: $,
|
|
892
|
-
fillColour: l,
|
|
893
|
-
strokeColour: p
|
|
894
|
-
});
|
|
895
|
-
}, Se = async (e) => {
|
|
896
|
-
const { fontUrl: t, fontSizeFallback: n, ...o } = e, a = !!o.colourMap, c = await Ot(t, a);
|
|
897
|
-
try {
|
|
898
|
-
return gt({ ...o, font: c });
|
|
899
|
-
} catch (f) {
|
|
900
|
-
if (n != null && f instanceof Error && f.message.startsWith("TOO_WIDE"))
|
|
901
|
-
return gt({ ...o, font: c, fontSize: n });
|
|
902
|
-
throw f;
|
|
903
|
-
}
|
|
904
|
-
};
|
|
905
|
-
export {
|
|
906
|
-
Nt as DEFAULT_OUTLINE_FACTOR,
|
|
907
|
-
G as DEFAULT_SPACING,
|
|
908
|
-
pt as LINE_HEIGHT,
|
|
909
|
-
mt as generateCurvedBaseline,
|
|
910
|
-
zt as generateFlatBaseline,
|
|
911
|
-
ve as getFontCache,
|
|
912
|
-
$e as getFontColours,
|
|
913
|
-
Rt as getFontSizeFromPhysicalSize,
|
|
914
|
-
Se as getRenderedText,
|
|
915
|
-
ct as getTextMetricsAtFontSize,
|
|
916
|
-
Ot as loadFont,
|
|
917
|
-
qt as normaliseBaselineOption,
|
|
918
|
-
gt as renderText,
|
|
919
|
-
Ht as validateCustomBaselinePath
|
|
693
|
+
//#endregion
|
|
694
|
+
//#region src/rendering/index.ts
|
|
695
|
+
var J = (e, t, n) => e / n * t, Y = ({ font: e, baselinePath: t, text: n, fontSize: r, spacing: i = T, horizontalAlignment: a = "centre", colourMap: s }) => {
|
|
696
|
+
let { outlineWidth: c, letterSpacing: l, letterSpacingOutline: u } = i, d = new o(t), f = c ? r * c * 2 : 0, p = d.getTotalLength(), m = e.getPaths(n, 0, 0, r, { drawSVG: !1 }), h = e.getPath(n, 0, 0, r, { drawSVG: !1 }).getBoundingBox(), g = h.x1 - f / 2, _ = h.x2 + f / 2 - g, v = c > 0 ? u : l, y = v ? v * r : 0;
|
|
697
|
+
a === "distributed" && (y = n.length === 1 ? 0 : (p - _) / (n.length - 1));
|
|
698
|
+
let b = y * (n.length - 1), x = _ + b, S = 0 - g;
|
|
699
|
+
a === "centre" ? S = (p - x) / 2 - g : a === "right" && (S = p - _ - g - b);
|
|
700
|
+
let C = [];
|
|
701
|
+
for (let t = 0; t < m.length; t++) {
|
|
702
|
+
let i = m[t], a = i.getBoundingBox(), o = e.charToGlyph(n[t]), { advanceWidth: c } = o;
|
|
703
|
+
if (!c) throw Error(`No advance width for character: ${n[t]} in font ${e.names.fontFamily}`);
|
|
704
|
+
let { x1: l, x2: u } = o.getBoundingBox(), f = J(c, r, e.unitsPerEm), h = J(u - l, r, e.unitsPerEm), g = S + a.x1;
|
|
705
|
+
if (t > 0 && (g += y * t), g + h > p) throw Error(`TOO_WIDE: character "${n[t]}" at index ${t} exceeds baseline path length (${Math.round(g + h)} > ${Math.round(p)})`);
|
|
706
|
+
let _ = g + f / 2, v = d.getTangentAtLength(_), b = Math.atan2(v.y, v.x) * 180 / Math.PI, x = d.getPointAtLength(g), w = x.x, T = x.y, O = a.x2 - a.x1, k = new E(a.x1 + O / 2, 0), A = D(new E(a.x1, 0), b, k), j = w - A.X, M = T - A.Y, N = ge();
|
|
707
|
+
N = N.translate(j, M);
|
|
708
|
+
let P;
|
|
709
|
+
if (b) {
|
|
710
|
+
let e = a.x1 + O / 2;
|
|
711
|
+
N = N.translate(e, 0), N = N.rotate(b), N = N.translate(-e, 0), P = `translate(${j} ${M}) translate(${e} 0) rotate(${b}) translate(${-e} 0)`;
|
|
712
|
+
} else P = `translate(${j} ${M})`;
|
|
713
|
+
let F = i.toPathData(2);
|
|
714
|
+
F.length && !F.endsWith("Z") && (F += "Z", F = F.replace(/M/g, "ZM"), F = F.substring(1));
|
|
715
|
+
let I;
|
|
716
|
+
if (e.svgGlyphs) {
|
|
717
|
+
let n = e.svgGlyphs.get(o.index);
|
|
718
|
+
if (n) {
|
|
719
|
+
let e = ue(n.svg);
|
|
720
|
+
e = fe(e, `g${o.index}-${t}`), s && (e = he(e, s)), I = {
|
|
721
|
+
content: e,
|
|
722
|
+
viewBox: n.viewbox,
|
|
723
|
+
x: a.x1,
|
|
724
|
+
y: a.y1,
|
|
725
|
+
width: a.x2 - a.x1,
|
|
726
|
+
height: a.y2 - a.y1,
|
|
727
|
+
glyphIndex: o.index
|
|
728
|
+
};
|
|
729
|
+
}
|
|
730
|
+
}
|
|
731
|
+
C.push({
|
|
732
|
+
path: i,
|
|
733
|
+
matrix: N,
|
|
734
|
+
attributes: {
|
|
735
|
+
d: F,
|
|
736
|
+
"data-character": _e(n[t]),
|
|
737
|
+
transform: P
|
|
738
|
+
},
|
|
739
|
+
glyphData: {
|
|
740
|
+
index: o.index,
|
|
741
|
+
bbox: a
|
|
742
|
+
},
|
|
743
|
+
...I ? { svgGlyph: I } : {}
|
|
744
|
+
});
|
|
745
|
+
}
|
|
746
|
+
return C;
|
|
747
|
+
}, X = { hex: "#FFFFFF" }, Z = (e, t) => {
|
|
748
|
+
let n = `data-${e}-colour-url`, r = [`${e}="${t.hex}"`];
|
|
749
|
+
return t.reference && r.push(`${n}="${t.reference}"`), r.join(" ");
|
|
750
|
+
}, Q = (e, t) => {
|
|
751
|
+
let { attributes: n, svgGlyph: r } = e;
|
|
752
|
+
return r ? `<g transform="${n.transform}" data-character="${n["data-character"]}"><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="${r.viewBox}" width="${r.width}" height="${r.height}" x="${r.x}" y="${r.y}" data-glyph-index="${r.glyphIndex}">${r.content}</svg></g>` : `<path d="${n.d}" ${Z("fill", t)} transform="${n.transform}" data-character="${n["data-character"]}"/>`;
|
|
753
|
+
}, ve = ({ boxDimensions: e, paths: t, spacing: n = T, fontSize: r = 0, fillColour: i = X, strokeColour: a = X }) => {
|
|
754
|
+
let { width: o, height: s } = e, { outlineWidth: c } = n, l = c > 0 && r > 0, u;
|
|
755
|
+
if (l) {
|
|
756
|
+
let e = r * c * 2;
|
|
757
|
+
u = `${t.filter((e) => !e.svgGlyph).map(({ attributes: t }) => `<path d="${t.d}" ${Z("fill", a)} ${Z("stroke", a)} stroke-width="${e}" stroke-linejoin="round" transform="${t.transform}" data-character="${t["data-character"]}"/>`).join("\n ")}\n ${t.map((e) => Q(e, i)).join("\n ")}`;
|
|
758
|
+
} else u = t.map((e) => Q(e, i)).join("\n ");
|
|
759
|
+
return `<svg xmlns="http://www.w3.org/2000/svg" width="${o}" height="${s}" viewBox="0 0 ${o} ${s}">${u ? `\n ${u}\n` : ""}</svg>`;
|
|
760
|
+
}, $ = (e) => {
|
|
761
|
+
let { text: t, font: n, physicalSize: r, fontSize: i, boxDimensions: a, spacing: o = T, verticalAlignment: s = "centre", baseline: c = "flat", horizontalAlignment: l = "left", fillColour: u = { hex: "#FFFFFF" }, strokeColour: d = { hex: "#FFFFFF" }, colourMap: f } = e, { width: p, height: m, physicalWidth: h, physicalHeight: g } = a;
|
|
762
|
+
if (p <= 0 || m <= 0) throw Error(`boxDimensions width and height must be positive (got ${p}x${m})`);
|
|
763
|
+
if (h <= 0 || g <= 0) throw Error(`boxDimensions physicalWidth and physicalHeight must be positive (got ${h}x${g})`);
|
|
764
|
+
if (r[0] <= 0) throw Error(`physicalSize height must be positive (got ${r[0]})`);
|
|
765
|
+
let _ = i ?? P({
|
|
766
|
+
font: n,
|
|
767
|
+
boxDimensions: a,
|
|
768
|
+
physicalSize: r,
|
|
769
|
+
spacing: o
|
|
770
|
+
}), v = O(c), y = t.split("\n").filter((e) => e.length > 0);
|
|
771
|
+
y.length || (y = [""]), (v.type === "curved" || v.type === "custom") && (y = [y.join("")]);
|
|
772
|
+
let b = y.map((e) => F({
|
|
773
|
+
font: n,
|
|
774
|
+
text: e,
|
|
775
|
+
fontSize: _,
|
|
776
|
+
spacing: o
|
|
777
|
+
})), x = Math.max(...b.map((e) => e.baseline)), S = x + Math.max(...b.map((e) => e.height - e.baseline)), w = y.length === 1 ? S : S + S * (y.length - 1) * C, E = [];
|
|
778
|
+
for (let e = 0; e < y.length; e++) {
|
|
779
|
+
let t;
|
|
780
|
+
switch (v.type) {
|
|
781
|
+
case "custom":
|
|
782
|
+
k(v.path), t = v.path;
|
|
783
|
+
break;
|
|
784
|
+
case "curved": {
|
|
785
|
+
let e = F({
|
|
786
|
+
font: n,
|
|
787
|
+
text: M(n),
|
|
788
|
+
fontSize: _,
|
|
789
|
+
spacing: o
|
|
790
|
+
});
|
|
791
|
+
t = j({
|
|
792
|
+
boxDimensions: a,
|
|
793
|
+
baseline: e.baseline,
|
|
794
|
+
textHeight: e.height,
|
|
795
|
+
verticalAlignment: s
|
|
796
|
+
});
|
|
797
|
+
break;
|
|
798
|
+
}
|
|
799
|
+
case "flat":
|
|
800
|
+
t = A({
|
|
801
|
+
boxDimensions: a,
|
|
802
|
+
totalTextHeight: w,
|
|
803
|
+
baseline: x,
|
|
804
|
+
lineHeight: S,
|
|
805
|
+
verticalAlignment: s,
|
|
806
|
+
lineNumber: e
|
|
807
|
+
});
|
|
808
|
+
break;
|
|
809
|
+
}
|
|
810
|
+
let r = Y({
|
|
811
|
+
font: n,
|
|
812
|
+
baselinePath: t,
|
|
813
|
+
text: y[e],
|
|
814
|
+
fontSize: _,
|
|
815
|
+
spacing: o,
|
|
816
|
+
horizontalAlignment: l,
|
|
817
|
+
colourMap: f
|
|
818
|
+
});
|
|
819
|
+
E.push(...r);
|
|
820
|
+
}
|
|
821
|
+
return ve({
|
|
822
|
+
boxDimensions: a,
|
|
823
|
+
paths: E,
|
|
824
|
+
spacing: o,
|
|
825
|
+
fontSize: _,
|
|
826
|
+
fillColour: u,
|
|
827
|
+
strokeColour: d
|
|
828
|
+
});
|
|
829
|
+
}, ye = async (e) => {
|
|
830
|
+
let { fontUrl: t, fontSizeFallback: n, ...r } = e, i = await x(t, !!r.colourMap);
|
|
831
|
+
try {
|
|
832
|
+
return $({
|
|
833
|
+
...r,
|
|
834
|
+
font: i
|
|
835
|
+
});
|
|
836
|
+
} catch (e) {
|
|
837
|
+
if (n != null && e instanceof Error && e.message.startsWith("TOO_WIDE")) return $({
|
|
838
|
+
...r,
|
|
839
|
+
font: i,
|
|
840
|
+
fontSize: n
|
|
841
|
+
});
|
|
842
|
+
throw e;
|
|
843
|
+
}
|
|
920
844
|
};
|
|
845
|
+
//#endregion
|
|
846
|
+
export { S as DEFAULT_OUTLINE_FACTOR, T as DEFAULT_SPACING, C as LINE_HEIGHT, j as generateCurvedBaseline, A as generateFlatBaseline, p as getFontCache, ce as getFontColours, P as getFontSizeFromPhysicalSize, ye as getRenderedText, F as getTextMetricsAtFontSize, x as loadFont, O as normaliseBaselineOption, $ as renderText, k as validateCustomBaselinePath };
|