ultra-text 1.0.0 → 1.0.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/README.md +267 -962
- package/THIRD_PARTY_NOTICES.md +3 -0
- package/dist/assets/{cpuSdf.worker-Du9o8q4p.js → cpuSdf.worker--X1Qpmdp.js} +148 -57
- package/dist/assets/cpuSdf.worker--X1Qpmdp.js.map +1 -0
- package/dist/atlas/appendAtlas.js +69 -26
- package/dist/atlas/appendAtlas.js.map +1 -1
- package/dist/atlas/buildAtlas.js +5 -15
- package/dist/atlas/buildAtlas.js.map +1 -1
- package/dist/atlas/cpuAtlas.d.ts +4 -1
- package/dist/atlas/cpuAtlas.js +8 -6
- package/dist/atlas/cpuAtlas.js.map +1 -1
- package/dist/atlas/cpuSdf.js +164 -50
- package/dist/atlas/cpuSdf.js.map +1 -1
- package/dist/atlas/cpuWorker.d.ts +5 -3
- package/dist/atlas/cpuWorker.js +119 -12
- package/dist/atlas/cpuWorker.js.map +1 -1
- package/dist/atlas/gpuAtlas.d.ts +7 -6
- package/dist/atlas/gpuAtlas.js +206 -247
- package/dist/atlas/gpuAtlas.js.map +1 -1
- package/dist/atlas/gpuCommon.d.ts +135 -0
- package/dist/atlas/gpuCommon.js +223 -0
- package/dist/atlas/gpuCommon.js.map +1 -0
- package/dist/atlas/jfaWgsl.js +59 -125
- package/dist/atlas/jfaWgsl.js.map +1 -1
- package/dist/atlas/rasterize.d.ts +2 -0
- package/dist/atlas/rasterize.js +104 -144
- package/dist/atlas/rasterize.js.map +1 -1
- package/dist/atlas/shapeRaster.js +2 -1
- package/dist/atlas/shapeRaster.js.map +1 -1
- package/dist/atlas/vanillaBounds.d.ts +64 -0
- package/dist/atlas/vanillaBounds.js +42 -0
- package/dist/atlas/vanillaBounds.js.map +1 -0
- package/dist/atlas/vanillaCore.d.ts +100 -0
- package/dist/atlas/vanillaCore.js +1012 -0
- package/dist/atlas/vanillaCore.js.map +1 -0
- package/dist/atlas/vanillaCpuAtlas.d.ts +9 -0
- package/dist/atlas/vanillaCpuAtlas.js +87 -0
- package/dist/atlas/vanillaCpuAtlas.js.map +1 -0
- package/dist/atlas/vanillaExtras.d.ts +8 -0
- package/dist/atlas/vanillaExtras.js +166 -0
- package/dist/atlas/vanillaExtras.js.map +1 -0
- package/dist/atlas/vanillaGpuHelpers.d.ts +232 -0
- package/dist/atlas/vanillaGpuHelpers.js +119 -0
- package/dist/atlas/vanillaGpuHelpers.js.map +1 -0
- package/dist/dom/DomSdf.js +263 -272
- package/dist/dom/DomSdf.js.map +1 -1
- package/dist/dom/DomSlug.d.ts +26 -0
- package/dist/dom/DomSlug.js +564 -0
- package/dist/dom/DomSlug.js.map +1 -0
- package/dist/dom/SlugText.d.ts +18 -0
- package/dist/dom/SlugText.js +94 -0
- package/dist/dom/SlugText.js.map +1 -0
- package/dist/dom/Text.js +4 -67
- package/dist/dom/Text.js.map +1 -1
- package/dist/dom/domAnalytic.d.ts +54 -0
- package/dist/dom/domAnalytic.js +282 -0
- package/dist/dom/domAnalytic.js.map +1 -0
- package/dist/dom/domExtras.d.ts +27 -0
- package/dist/dom/domExtras.js +137 -0
- package/dist/dom/domExtras.js.map +1 -0
- package/dist/dom/fontCanvas.d.ts +2 -0
- package/dist/dom/fontCanvas.js +119 -0
- package/dist/dom/fontCanvas.js.map +1 -0
- package/dist/dom/layoutSignature.js +156 -27
- package/dist/dom/layoutSignature.js.map +1 -1
- package/dist/dom/pretextLayout.js +55 -13
- package/dist/dom/pretextLayout.js.map +1 -1
- package/dist/dom/snapshot.js +563 -243
- package/dist/dom/snapshot.js.map +1 -1
- package/dist/dom/svgCapture.d.ts +8 -1
- package/dist/dom/svgCapture.js +75 -1
- package/dist/dom/svgCapture.js.map +1 -1
- package/dist/dom/textHost.d.ts +11 -0
- package/dist/dom/textHost.js +68 -0
- package/dist/dom/textHost.js.map +1 -0
- package/dist/dom/tone.js +76 -36
- package/dist/dom/tone.js.map +1 -1
- package/dist/index.js +4 -3
- package/dist/slug/SlugMaterial.d.ts +13 -4
- package/dist/slug/SlugMaterial.js +82 -12
- package/dist/slug/SlugMaterial.js.map +1 -1
- package/dist/slug/coverage.d.ts +17 -13
- package/dist/slug/coverage.js +195 -222
- package/dist/slug/coverage.js.map +1 -1
- package/dist/slug/preprocessCore.d.ts +6 -3
- package/dist/slug/preprocessCore.js +149 -95
- package/dist/slug/preprocessCore.js.map +1 -1
- package/dist/slug/runtime.d.ts +1 -0
- package/dist/slug/runtime.js +94 -46
- package/dist/slug/runtime.js.map +1 -1
- package/dist/slug/standaloneRuntime.d.ts +40 -0
- package/dist/slug/standaloneRuntime.js +175 -0
- package/dist/slug/standaloneRuntime.js.map +1 -0
- package/dist/slug/truetype.d.ts +22 -0
- package/dist/slug/truetype.js +467 -0
- package/dist/slug/truetype.js.map +1 -0
- package/dist/slug/vanillaCore.d.ts +340 -0
- package/dist/slug/vanillaCore.js +1621 -0
- package/dist/slug/vanillaCore.js.map +1 -0
- package/dist/slug-vanilla.d.ts +13 -0
- package/dist/slug-vanilla.js +13 -0
- package/dist/slug.d.ts +21 -0
- package/dist/slug.js +19 -0
- package/dist/text/GlyphTextMaterial.d.ts +11 -11
- package/dist/text/GlyphTextMaterial.js +102 -33
- package/dist/text/GlyphTextMaterial.js.map +1 -1
- package/dist/text/SdfTextMaterial.d.ts +5 -4
- package/dist/text/SdfTextMaterial.js +29 -9
- package/dist/text/SdfTextMaterial.js.map +1 -1
- package/dist/text/decorations.js +36 -19
- package/dist/text/decorations.js.map +1 -1
- package/dist/text/geometry.d.ts +3 -22
- package/dist/text/geometryUtils.d.ts +11 -1
- package/dist/text/geometryUtils.js +22 -1
- package/dist/text/geometryUtils.js.map +1 -1
- package/dist/text/glyphGeometry.d.ts +9 -0
- package/dist/text/glyphGeometry.js +353 -0
- package/dist/text/glyphGeometry.js.map +1 -0
- package/dist/text/index.d.ts +2 -1
- package/dist/text/rectGeometry.d.ts +13 -0
- package/dist/text/rectGeometry.js +97 -0
- package/dist/text/rectGeometry.js.map +1 -0
- package/dist/text/reflow.d.ts +18 -1
- package/dist/text/reflow.js +108 -38
- package/dist/text/reflow.js.map +1 -1
- package/dist/text/snap.d.ts +1 -0
- package/dist/text/snap.js +26 -0
- package/dist/text/snap.js.map +1 -0
- package/dist/types.d.ts +63 -14
- package/dist/vanilla.d.ts +13 -360
- package/dist/vanilla.js +8 -1402
- package/dist/windfoil/WindfoilMaterial.d.ts +2 -1
- package/dist/windfoil/WindfoilMaterial.js +8 -1
- package/dist/windfoil/WindfoilMaterial.js.map +1 -1
- package/dist/windfoil/abortable.d.ts +2 -0
- package/dist/windfoil/abortable.js +26 -0
- package/dist/windfoil/abortable.js.map +1 -0
- package/dist/windfoil/color.js +2 -1
- package/dist/windfoil/color.js.map +1 -1
- package/dist/windfoil/coverage.d.ts +3 -20
- package/dist/windfoil/coverage.js +7 -20
- package/dist/windfoil/coverage.js.map +1 -1
- package/dist/windfoil/emoji.js +1 -1
- package/dist/windfoil/emoji.js.map +1 -1
- package/dist/windfoil/emojiMetrics.js +1 -1
- package/dist/windfoil/emojiMetrics.js.map +1 -1
- package/dist/windfoil/geometry.d.ts +2 -2
- package/dist/windfoil/geometry.js +204 -64
- package/dist/windfoil/geometry.js.map +1 -1
- package/dist/windfoil/layerGrid.js +14 -10
- package/dist/windfoil/layerGrid.js.map +1 -1
- package/dist/windfoil/layerNormalization.d.ts +1 -1
- package/dist/windfoil/layerNormalization.js +1 -1
- package/dist/windfoil/layerNormalization.js.map +1 -1
- package/dist/windfoil/mixed.d.ts +1 -0
- package/dist/windfoil/mixed.js +44 -25
- package/dist/windfoil/mixed.js.map +1 -1
- package/dist/windfoil/outlineValidation.d.ts +86 -0
- package/dist/windfoil/outlineValidation.js +65 -0
- package/dist/windfoil/outlineValidation.js.map +1 -0
- package/dist/windfoil/preprocess.js +3 -2
- package/dist/windfoil/preprocess.js.map +1 -1
- package/dist/windfoil/preprocessCore.d.ts +5 -85
- package/dist/windfoil/preprocessCore.js +218 -209
- package/dist/windfoil/preprocessCore.js.map +1 -1
- package/dist/windfoil/requests.js +1 -1
- package/dist/windfoil/requests.js.map +1 -1
- package/dist/windfoil/runtime.d.ts +5 -2
- package/dist/windfoil/runtime.js +63 -40
- package/dist/windfoil/runtime.js.map +1 -1
- package/dist/windfoil/shapeResources.js +2 -1
- package/dist/windfoil/shapeResources.js.map +1 -1
- package/dist/windfoil/shapes.js +1 -1
- package/dist/windfoil/skirt.d.ts +22 -0
- package/dist/windfoil/skirt.js +20 -0
- package/dist/windfoil/skirt.js.map +1 -0
- package/dist/windfoil/storage.d.ts +62 -4
- package/dist/windfoil/storage.js +143 -28
- package/dist/windfoil/storage.js.map +1 -1
- package/dist/windfoil/trace/contours.d.ts +3 -3
- package/dist/windfoil/trace/contours.js +228 -137
- package/dist/windfoil/trace/contours.js.map +1 -1
- package/dist/windfoil/trace/fit.d.ts +3 -7
- package/dist/windfoil/trace/fit.js +668 -376
- package/dist/windfoil/trace/fit.js.map +1 -1
- package/dist/windfoil/trace/outline.js +60 -35
- package/dist/windfoil/trace/outline.js.map +1 -1
- package/dist/windfoil/trace/types.d.ts +15 -3
- package/dist/windfoil/tracedOutlines.d.ts +37 -1
- package/dist/windfoil/tracedOutlines.js +228 -64
- package/dist/windfoil/tracedOutlines.js.map +1 -1
- package/package.json +60 -11
- package/skills/ultra-text/SKILL.md +114 -0
- package/skills/ultra-text/references/frameworks.md +43 -0
- package/skills/ultra-text/references/three-tsl.md +78 -0
- package/skills/ultra-text/references/vanilla-webgpu.md +96 -0
- package/dist/assets/cpuSdf.worker-Du9o8q4p.js.map +0 -1
- package/dist/text/geometry.js +0 -348
- package/dist/text/geometry.js.map +0 -1
- package/dist/vanilla.js.map +0 -1
|
@@ -0,0 +1,467 @@
|
|
|
1
|
+
// src/slug/truetype.ts
|
|
2
|
+
function isArrayBufferLike(value) {
|
|
3
|
+
return value instanceof ArrayBuffer || Object.prototype.toString.call(value) === "[object ArrayBuffer]";
|
|
4
|
+
}
|
|
5
|
+
function toDataView(source) {
|
|
6
|
+
if (isArrayBufferLike(source)) return new DataView(source);
|
|
7
|
+
if (ArrayBuffer.isView(source)) return new DataView(source.buffer, source.byteOffset, source.byteLength);
|
|
8
|
+
throw new TypeError("parseTrueTypeFont: expected an ArrayBuffer or ArrayBufferView");
|
|
9
|
+
}
|
|
10
|
+
var EMPTY_BBOX = Object.freeze([
|
|
11
|
+
0,
|
|
12
|
+
0,
|
|
13
|
+
0,
|
|
14
|
+
0
|
|
15
|
+
]);
|
|
16
|
+
var EMPTY_QUADRATICS = /* @__PURE__ */ new Float32Array(0);
|
|
17
|
+
var ttEnds = /* @__PURE__ */ new Uint16Array(32);
|
|
18
|
+
var ttFlags = /* @__PURE__ */ new Uint8Array(256);
|
|
19
|
+
var ttXs = /* @__PURE__ */ new Int32Array(256);
|
|
20
|
+
var ttYs = /* @__PURE__ */ new Int32Array(256);
|
|
21
|
+
var ttExX = /* @__PURE__ */ new Float64Array(512);
|
|
22
|
+
var ttExY = /* @__PURE__ */ new Float64Array(512);
|
|
23
|
+
var ttExOn = /* @__PURE__ */ new Uint8Array(512);
|
|
24
|
+
var ttQuads = /* @__PURE__ */ new Float32Array(1024);
|
|
25
|
+
var compX = /* @__PURE__ */ new Float64Array(256);
|
|
26
|
+
var compY = /* @__PURE__ */ new Float64Array(256);
|
|
27
|
+
var compOn = /* @__PURE__ */ new Uint8Array(256);
|
|
28
|
+
var compStarts = /* @__PURE__ */ new Uint32Array(32);
|
|
29
|
+
var compLens = /* @__PURE__ */ new Uint32Array(32);
|
|
30
|
+
function ensurePointScratch(count) {
|
|
31
|
+
if (count <= ttFlags.length) return;
|
|
32
|
+
let size = ttFlags.length;
|
|
33
|
+
while (size < count) size *= 2;
|
|
34
|
+
ttFlags = new Uint8Array(size);
|
|
35
|
+
ttXs = new Int32Array(size);
|
|
36
|
+
ttYs = new Int32Array(size);
|
|
37
|
+
}
|
|
38
|
+
function ensureCompositePoints(required, currentLen) {
|
|
39
|
+
if (required <= compX.length) return;
|
|
40
|
+
let size = compX.length;
|
|
41
|
+
while (size < required) size *= 2;
|
|
42
|
+
const nx = new Float64Array(size);
|
|
43
|
+
const ny = new Float64Array(size);
|
|
44
|
+
const no = new Uint8Array(size);
|
|
45
|
+
if (currentLen > 0) {
|
|
46
|
+
nx.set(compX.subarray(0, currentLen));
|
|
47
|
+
ny.set(compY.subarray(0, currentLen));
|
|
48
|
+
no.set(compOn.subarray(0, currentLen));
|
|
49
|
+
}
|
|
50
|
+
compX = nx;
|
|
51
|
+
compY = ny;
|
|
52
|
+
compOn = no;
|
|
53
|
+
}
|
|
54
|
+
function ensureCompositeContours(required, currentLen) {
|
|
55
|
+
if (required <= compStarts.length) return;
|
|
56
|
+
let size = compStarts.length;
|
|
57
|
+
while (size < required) size *= 2;
|
|
58
|
+
const ns = new Uint32Array(size);
|
|
59
|
+
const nl = new Uint32Array(size);
|
|
60
|
+
if (currentLen > 0) {
|
|
61
|
+
ns.set(compStarts.subarray(0, currentLen));
|
|
62
|
+
nl.set(compLens.subarray(0, currentLen));
|
|
63
|
+
}
|
|
64
|
+
compStarts = ns;
|
|
65
|
+
compLens = nl;
|
|
66
|
+
}
|
|
67
|
+
function ensureExpandedScratch(count) {
|
|
68
|
+
if (count <= ttExX.length) return;
|
|
69
|
+
let size = ttExX.length;
|
|
70
|
+
while (size < count) size *= 2;
|
|
71
|
+
ttExX = new Float64Array(size);
|
|
72
|
+
ttExY = new Float64Array(size);
|
|
73
|
+
ttExOn = new Uint8Array(size);
|
|
74
|
+
}
|
|
75
|
+
function ensureQuadScratch(required, currentLen) {
|
|
76
|
+
if (required <= ttQuads.length) return;
|
|
77
|
+
let size = ttQuads.length;
|
|
78
|
+
while (size < required) size *= 2;
|
|
79
|
+
const next = new Float32Array(size);
|
|
80
|
+
if (currentLen > 0) next.set(ttQuads.subarray(0, currentLen));
|
|
81
|
+
ttQuads = next;
|
|
82
|
+
}
|
|
83
|
+
function emitContourRange(xs, ys, onMask, first, len, quadLen) {
|
|
84
|
+
if (len < 2) return quadLen;
|
|
85
|
+
ensureExpandedScratch(len * 2);
|
|
86
|
+
let exLen = 0;
|
|
87
|
+
let firstOn = -1;
|
|
88
|
+
for (let i = 0; i < len; i++) {
|
|
89
|
+
const p0 = first + i;
|
|
90
|
+
const p1 = first + (i + 1 === len ? 0 : i + 1);
|
|
91
|
+
const x0 = xs[p0];
|
|
92
|
+
const y0 = ys[p0];
|
|
93
|
+
const on0 = onMask[p0] & 1;
|
|
94
|
+
if (on0 && firstOn < 0) firstOn = exLen;
|
|
95
|
+
ttExX[exLen] = x0;
|
|
96
|
+
ttExY[exLen] = y0;
|
|
97
|
+
ttExOn[exLen] = on0;
|
|
98
|
+
exLen++;
|
|
99
|
+
if (!on0 && !(onMask[p1] & 1)) {
|
|
100
|
+
if (firstOn < 0) firstOn = exLen;
|
|
101
|
+
ttExX[exLen] = (x0 + xs[p1]) * .5;
|
|
102
|
+
ttExY[exLen] = (y0 + ys[p1]) * .5;
|
|
103
|
+
ttExOn[exLen] = 1;
|
|
104
|
+
exLen++;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
if (firstOn < 0) return quadLen;
|
|
108
|
+
ensureQuadScratch(quadLen + exLen * 6, quadLen);
|
|
109
|
+
let curX = ttExX[firstOn];
|
|
110
|
+
let curY = ttExY[firstOn];
|
|
111
|
+
let step = 1;
|
|
112
|
+
while (step <= exLen) {
|
|
113
|
+
const rawIdx = firstOn + step;
|
|
114
|
+
const idx = rawIdx >= exLen ? rawIdx - exLen : rawIdx;
|
|
115
|
+
if (ttExOn[idx]) {
|
|
116
|
+
const px = ttExX[idx];
|
|
117
|
+
const py = ttExY[idx];
|
|
118
|
+
ttQuads[quadLen++] = curX;
|
|
119
|
+
ttQuads[quadLen++] = curY;
|
|
120
|
+
ttQuads[quadLen++] = (curX + px) * .5;
|
|
121
|
+
ttQuads[quadLen++] = (curY + py) * .5;
|
|
122
|
+
ttQuads[quadLen++] = px;
|
|
123
|
+
ttQuads[quadLen++] = py;
|
|
124
|
+
curX = px;
|
|
125
|
+
curY = py;
|
|
126
|
+
step++;
|
|
127
|
+
} else {
|
|
128
|
+
const rawEnd = firstOn + step + 1;
|
|
129
|
+
const endIdx = rawEnd >= exLen ? rawEnd - exLen : rawEnd;
|
|
130
|
+
const endX = ttExX[endIdx];
|
|
131
|
+
const endY = ttExY[endIdx];
|
|
132
|
+
ttQuads[quadLen++] = curX;
|
|
133
|
+
ttQuads[quadLen++] = curY;
|
|
134
|
+
ttQuads[quadLen++] = ttExX[idx];
|
|
135
|
+
ttQuads[quadLen++] = ttExY[idx];
|
|
136
|
+
ttQuads[quadLen++] = endX;
|
|
137
|
+
ttQuads[quadLen++] = endY;
|
|
138
|
+
curX = endX;
|
|
139
|
+
curY = endY;
|
|
140
|
+
step += 2;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
return quadLen;
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Lightweight runtime TrueType (`.ttf` `glyf` table) outline reader for Slug.
|
|
147
|
+
* Supports Unicode `cmap` formats 4 and 12, simple quadratic contours (including
|
|
148
|
+
* implied midpoints and all-off-curve rings), and offset/affine composite glyphs.
|
|
149
|
+
*/
|
|
150
|
+
function parseTrueTypeFont(source) {
|
|
151
|
+
const view = toDataView(source);
|
|
152
|
+
if (view.byteLength < 12) throw new Error("parseTrueTypeFont: buffer is too short to be a TrueType font");
|
|
153
|
+
const sfntVersion = view.getUint32(0);
|
|
154
|
+
if (sfntVersion === 2001684018 || sfntVersion === 2001684038) throw new Error("parseTrueTypeFont: compressed WOFF/WOFF2 buffers are unsupported; pass an uncompressed .ttf buffer or omit outlineProvider to trace loaded webfonts");
|
|
155
|
+
if (sfntVersion === 1330926671) throw new Error("parseTrueTypeFont: OpenType CFF (.otf) outlines are unsupported; pass a TrueType (.ttf) buffer or omit outlineProvider to trace loaded webfonts");
|
|
156
|
+
const numTables = view.getUint16(4);
|
|
157
|
+
const tables = /* @__PURE__ */ new Map();
|
|
158
|
+
for (let i = 0; i < numTables; i++) {
|
|
159
|
+
const at = 12 + i * 16;
|
|
160
|
+
if (at + 16 > view.byteLength) break;
|
|
161
|
+
const tag = String.fromCharCode(view.getUint8(at), view.getUint8(at + 1), view.getUint8(at + 2), view.getUint8(at + 3));
|
|
162
|
+
tables.set(tag, view.getUint32(at + 8));
|
|
163
|
+
}
|
|
164
|
+
const table = (tag) => {
|
|
165
|
+
const offset = tables.get(tag);
|
|
166
|
+
if (offset === void 0) throw new Error(`parseTrueTypeFont: missing "${tag}" table`);
|
|
167
|
+
return offset;
|
|
168
|
+
};
|
|
169
|
+
const head = table("head");
|
|
170
|
+
const unitsPerEm = view.getUint16(head + 18);
|
|
171
|
+
const longOffsets = view.getInt16(head + 50) !== 0;
|
|
172
|
+
const hhea = table("hhea");
|
|
173
|
+
const ascent = view.getInt16(hhea + 4);
|
|
174
|
+
const descent = view.getInt16(hhea + 6);
|
|
175
|
+
const glyphCount = view.getUint16(table("maxp") + 4);
|
|
176
|
+
const loca = table("loca");
|
|
177
|
+
const glyf = table("glyf");
|
|
178
|
+
const glyphOffset = (index) => longOffsets ? view.getUint32(loca + index * 4) : view.getUint16(loca + index * 2) * 2;
|
|
179
|
+
const cmap = /* @__PURE__ */ new Map();
|
|
180
|
+
const cmapBase = table("cmap");
|
|
181
|
+
const subtableCount = view.getUint16(cmapBase + 2);
|
|
182
|
+
let chosen = -1;
|
|
183
|
+
let chosenFormat = 0;
|
|
184
|
+
for (let i = 0; i < subtableCount; i++) {
|
|
185
|
+
const at = cmapBase + 4 + i * 8;
|
|
186
|
+
const platform = view.getUint16(at);
|
|
187
|
+
const encoding = view.getUint16(at + 2);
|
|
188
|
+
const offset = cmapBase + view.getUint32(at + 4);
|
|
189
|
+
const format = view.getUint16(offset);
|
|
190
|
+
if ((platform === 0 || platform === 3 && (encoding === 1 || encoding === 10)) && (format === 12 || format === 4 && chosenFormat !== 12)) {
|
|
191
|
+
chosen = offset;
|
|
192
|
+
chosenFormat = format;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
if (chosen < 0) throw new Error("parseTrueTypeFont: font has no Unicode cmap subtable");
|
|
196
|
+
if (chosenFormat === 4) {
|
|
197
|
+
const segments = view.getUint16(chosen + 6) >> 1;
|
|
198
|
+
const ends = chosen + 14;
|
|
199
|
+
const starts = ends + segments * 2 + 2;
|
|
200
|
+
const deltas = starts + segments * 2;
|
|
201
|
+
const ranges = deltas + segments * 2;
|
|
202
|
+
for (let segment = 0; segment < segments; segment++) {
|
|
203
|
+
const end = view.getUint16(ends + segment * 2);
|
|
204
|
+
const start = view.getUint16(starts + segment * 2);
|
|
205
|
+
const delta = view.getInt16(deltas + segment * 2);
|
|
206
|
+
const rangeOffset = view.getUint16(ranges + segment * 2);
|
|
207
|
+
for (let code = start; code <= end && code !== 65535; code++) {
|
|
208
|
+
let glyph = code;
|
|
209
|
+
if (rangeOffset !== 0) {
|
|
210
|
+
glyph = view.getUint16(ranges + segment * 2 + rangeOffset + (code - start) * 2);
|
|
211
|
+
if (glyph === 0) continue;
|
|
212
|
+
}
|
|
213
|
+
glyph = glyph + delta & 65535;
|
|
214
|
+
if (glyph !== 0) cmap.set(code, glyph);
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
} else {
|
|
218
|
+
const groups = view.getUint32(chosen + 12);
|
|
219
|
+
for (let group = 0; group < groups; group++) {
|
|
220
|
+
const at = chosen + 16 + group * 12;
|
|
221
|
+
const start = view.getUint32(at);
|
|
222
|
+
const end = view.getUint32(at + 4);
|
|
223
|
+
const first = view.getUint32(at + 8);
|
|
224
|
+
for (let code = start; code <= end; code++) {
|
|
225
|
+
const glyph = first + code - start;
|
|
226
|
+
if (glyph !== 0) cmap.set(code, glyph);
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
function readSimplePoints(at, contourCount) {
|
|
231
|
+
if (contourCount === 0) return 0;
|
|
232
|
+
if (contourCount > ttEnds.length) {
|
|
233
|
+
let size = ttEnds.length;
|
|
234
|
+
while (size < contourCount) size *= 2;
|
|
235
|
+
ttEnds = new Uint16Array(size);
|
|
236
|
+
}
|
|
237
|
+
for (let c = 0; c < contourCount; c++) ttEnds[c] = view.getUint16(at + 10 + c * 2);
|
|
238
|
+
const pointCount = ttEnds[contourCount - 1] + 1;
|
|
239
|
+
let cursor = at + 10 + contourCount * 2;
|
|
240
|
+
cursor += 2 + view.getUint16(cursor);
|
|
241
|
+
ensurePointScratch(pointCount);
|
|
242
|
+
let fIdx = 0;
|
|
243
|
+
while (fIdx < pointCount) {
|
|
244
|
+
const flag = view.getUint8(cursor++);
|
|
245
|
+
ttFlags[fIdx++] = flag;
|
|
246
|
+
if (flag & 8) {
|
|
247
|
+
const repeat = view.getUint8(cursor++);
|
|
248
|
+
const end = Math.min(pointCount, fIdx + repeat);
|
|
249
|
+
while (fIdx < end) ttFlags[fIdx++] = flag;
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
let vx = 0;
|
|
253
|
+
for (let i = 0; i < pointCount; i++) {
|
|
254
|
+
const flag = ttFlags[i];
|
|
255
|
+
if (flag & 2) {
|
|
256
|
+
const delta = view.getUint8(cursor++);
|
|
257
|
+
vx += flag & 16 ? delta : -delta;
|
|
258
|
+
} else if (!(flag & 16)) {
|
|
259
|
+
vx += view.getInt16(cursor);
|
|
260
|
+
cursor += 2;
|
|
261
|
+
}
|
|
262
|
+
ttXs[i] = vx;
|
|
263
|
+
}
|
|
264
|
+
let vy = 0;
|
|
265
|
+
for (let i = 0; i < pointCount; i++) {
|
|
266
|
+
const flag = ttFlags[i];
|
|
267
|
+
if (flag & 4) {
|
|
268
|
+
const delta = view.getUint8(cursor++);
|
|
269
|
+
vy += flag & 32 ? delta : -delta;
|
|
270
|
+
} else if (!(flag & 32)) {
|
|
271
|
+
vy += view.getInt16(cursor);
|
|
272
|
+
cursor += 2;
|
|
273
|
+
}
|
|
274
|
+
ttYs[i] = vy;
|
|
275
|
+
}
|
|
276
|
+
return pointCount;
|
|
277
|
+
}
|
|
278
|
+
function decodeSimpleGlyph(at, contourCount, bbox) {
|
|
279
|
+
if (contourCount === 0) return Object.freeze({
|
|
280
|
+
unitsPerEm,
|
|
281
|
+
ascent,
|
|
282
|
+
descent,
|
|
283
|
+
bbox,
|
|
284
|
+
quadratics: EMPTY_QUADRATICS
|
|
285
|
+
});
|
|
286
|
+
readSimplePoints(at, contourCount);
|
|
287
|
+
let quadLen = 0;
|
|
288
|
+
let first = 0;
|
|
289
|
+
for (let c = 0; c < contourCount; c++) {
|
|
290
|
+
const last = ttEnds[c];
|
|
291
|
+
quadLen = emitContourRange(ttXs, ttYs, ttFlags, first, last - first + 1, quadLen);
|
|
292
|
+
first = last + 1;
|
|
293
|
+
}
|
|
294
|
+
return Object.freeze({
|
|
295
|
+
unitsPerEm,
|
|
296
|
+
ascent,
|
|
297
|
+
descent,
|
|
298
|
+
bbox,
|
|
299
|
+
quadratics: ttQuads.slice(0, quadLen)
|
|
300
|
+
});
|
|
301
|
+
}
|
|
302
|
+
function appendGlyphContours(index, a, b, c, d, dx, dy, depth, state) {
|
|
303
|
+
if (index < 0 || index >= glyphCount || depth > 8) return false;
|
|
304
|
+
const start = glyphOffset(index);
|
|
305
|
+
if (glyphOffset(index + 1) <= start) return true;
|
|
306
|
+
const at = glyf + start;
|
|
307
|
+
const contourCount = view.getInt16(at);
|
|
308
|
+
if (contourCount >= 0) {
|
|
309
|
+
const pointCount = readSimplePoints(at, contourCount);
|
|
310
|
+
if (pointCount === 0) return true;
|
|
311
|
+
ensureCompositePoints(state.pointLen + pointCount, state.pointLen);
|
|
312
|
+
ensureCompositeContours(state.contourLen + contourCount, state.contourLen);
|
|
313
|
+
const ptBase = state.pointLen;
|
|
314
|
+
for (let p = 0; p < pointCount; p++) {
|
|
315
|
+
const x = ttXs[p];
|
|
316
|
+
const y = ttYs[p];
|
|
317
|
+
compX[ptBase + p] = a * x + c * y + dx;
|
|
318
|
+
compY[ptBase + p] = b * x + d * y + dy;
|
|
319
|
+
compOn[ptBase + p] = ttFlags[p] & 1;
|
|
320
|
+
}
|
|
321
|
+
let first = 0;
|
|
322
|
+
for (let k = 0; k < contourCount; k++) {
|
|
323
|
+
const last = ttEnds[k];
|
|
324
|
+
compStarts[state.contourLen] = ptBase + first;
|
|
325
|
+
compLens[state.contourLen] = last - first + 1;
|
|
326
|
+
state.contourLen++;
|
|
327
|
+
first = last + 1;
|
|
328
|
+
}
|
|
329
|
+
state.pointLen = ptBase + pointCount;
|
|
330
|
+
return true;
|
|
331
|
+
}
|
|
332
|
+
let cursor = at + 10;
|
|
333
|
+
for (;;) {
|
|
334
|
+
const flags = view.getUint16(cursor);
|
|
335
|
+
const component = view.getUint16(cursor + 2);
|
|
336
|
+
cursor += 4;
|
|
337
|
+
if (!(flags & 2)) return false;
|
|
338
|
+
const cdx = flags & 1 ? view.getInt16(cursor) : view.getInt8(cursor);
|
|
339
|
+
const cdy = flags & 1 ? view.getInt16(cursor + 2) : view.getInt8(cursor + 1);
|
|
340
|
+
cursor += flags & 1 ? 4 : 2;
|
|
341
|
+
let ca = 1, cb = 0, cc = 0, cd = 1;
|
|
342
|
+
if (flags & 8) {
|
|
343
|
+
ca = cd = view.getInt16(cursor) / 16384;
|
|
344
|
+
cursor += 2;
|
|
345
|
+
} else if (flags & 64) {
|
|
346
|
+
ca = view.getInt16(cursor) / 16384;
|
|
347
|
+
cd = view.getInt16(cursor + 2) / 16384;
|
|
348
|
+
cursor += 4;
|
|
349
|
+
} else if (flags & 128) {
|
|
350
|
+
ca = view.getInt16(cursor) / 16384;
|
|
351
|
+
cb = view.getInt16(cursor + 2) / 16384;
|
|
352
|
+
cc = view.getInt16(cursor + 4) / 16384;
|
|
353
|
+
cd = view.getInt16(cursor + 6) / 16384;
|
|
354
|
+
cursor += 8;
|
|
355
|
+
}
|
|
356
|
+
if (!appendGlyphContours(component, a * ca + c * cb, b * ca + d * cb, a * cc + c * cd, b * cc + d * cd, a * cdx + c * cdy + dx, b * cdx + d * cdy + dy, depth + 1, state)) return false;
|
|
357
|
+
if (!(flags & 32)) return true;
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
function decodeCompositeGlyph(at, index) {
|
|
361
|
+
const bbox = Object.freeze([
|
|
362
|
+
view.getInt16(at + 2),
|
|
363
|
+
view.getInt16(at + 4),
|
|
364
|
+
view.getInt16(at + 6),
|
|
365
|
+
view.getInt16(at + 8)
|
|
366
|
+
]);
|
|
367
|
+
const state = {
|
|
368
|
+
pointLen: 0,
|
|
369
|
+
contourLen: 0
|
|
370
|
+
};
|
|
371
|
+
if (!appendGlyphContours(index, 1, 0, 0, 1, 0, 0, 0, state)) return null;
|
|
372
|
+
let quadLen = 0;
|
|
373
|
+
for (let k = 0; k < state.contourLen; k++) quadLen = emitContourRange(compX, compY, compOn, compStarts[k], compLens[k], quadLen);
|
|
374
|
+
return Object.freeze({
|
|
375
|
+
unitsPerEm,
|
|
376
|
+
ascent,
|
|
377
|
+
descent,
|
|
378
|
+
bbox,
|
|
379
|
+
quadratics: ttQuads.slice(0, quadLen)
|
|
380
|
+
});
|
|
381
|
+
}
|
|
382
|
+
const cache = /* @__PURE__ */ new Map();
|
|
383
|
+
const outlineForCodePoint = (codePoint) => {
|
|
384
|
+
const index = cmap.get(codePoint);
|
|
385
|
+
if (index === void 0) return null;
|
|
386
|
+
let entry = cache.get(index);
|
|
387
|
+
if (entry === void 0 && !cache.has(index)) {
|
|
388
|
+
if (index < 0 || index >= glyphCount) entry = null;
|
|
389
|
+
else {
|
|
390
|
+
const start = glyphOffset(index);
|
|
391
|
+
if (glyphOffset(index + 1) <= start) entry = Object.freeze({
|
|
392
|
+
unitsPerEm,
|
|
393
|
+
ascent,
|
|
394
|
+
descent,
|
|
395
|
+
bbox: EMPTY_BBOX,
|
|
396
|
+
quadratics: EMPTY_QUADRATICS
|
|
397
|
+
});
|
|
398
|
+
else {
|
|
399
|
+
const at = glyf + start;
|
|
400
|
+
const contourCount = view.getInt16(at);
|
|
401
|
+
if (contourCount >= 0) entry = decodeSimpleGlyph(at, contourCount, Object.freeze([
|
|
402
|
+
view.getInt16(at + 2),
|
|
403
|
+
view.getInt16(at + 4),
|
|
404
|
+
view.getInt16(at + 6),
|
|
405
|
+
view.getInt16(at + 8)
|
|
406
|
+
]));
|
|
407
|
+
else entry = decodeCompositeGlyph(at, index);
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
cache.set(index, entry);
|
|
411
|
+
}
|
|
412
|
+
return entry ?? null;
|
|
413
|
+
};
|
|
414
|
+
return {
|
|
415
|
+
unitsPerEm,
|
|
416
|
+
ascent,
|
|
417
|
+
descent,
|
|
418
|
+
glyphCount,
|
|
419
|
+
has(codePoint) {
|
|
420
|
+
return cmap.has(codePoint);
|
|
421
|
+
},
|
|
422
|
+
outlineForCodePoint,
|
|
423
|
+
outline(character) {
|
|
424
|
+
const code = character.codePointAt(0);
|
|
425
|
+
if (code === void 0 || character.length !== (code > 65535 ? 2 : 1)) return null;
|
|
426
|
+
return outlineForCodePoint(code);
|
|
427
|
+
}
|
|
428
|
+
};
|
|
429
|
+
}
|
|
430
|
+
function asParsedFont(entry) {
|
|
431
|
+
if ("outline" in entry && typeof entry.outline === "function") return entry;
|
|
432
|
+
return parseTrueTypeFont(entry);
|
|
433
|
+
}
|
|
434
|
+
function normalizeFamilyToken(family) {
|
|
435
|
+
return family.trim().replace(/^['"]|['"]$/g, "").toLowerCase();
|
|
436
|
+
}
|
|
437
|
+
/**
|
|
438
|
+
* Creates a `WindfoilOutlineProvider` from a single `.ttf` buffer/`TrueTypeFont` or a family-keyed
|
|
439
|
+
* map/object of `.ttf` buffers (with optional `'*'` fallback key).
|
|
440
|
+
*/
|
|
441
|
+
function createTrueTypeOutlineProvider(source) {
|
|
442
|
+
if (isArrayBufferLike(source) || ArrayBuffer.isView(source) || "outline" in source && typeof source.outline === "function") {
|
|
443
|
+
const font = asParsedFont(source);
|
|
444
|
+
return (request, signal) => {
|
|
445
|
+
signal?.throwIfAborted();
|
|
446
|
+
return font.outline(request.character);
|
|
447
|
+
};
|
|
448
|
+
}
|
|
449
|
+
const families = /* @__PURE__ */ new Map();
|
|
450
|
+
const entries = source instanceof Map ? source.entries() : Object.entries(source);
|
|
451
|
+
for (const [key, value] of entries) families.set(key === "*" ? "*" : normalizeFamilyToken(key), asParsedFont(value));
|
|
452
|
+
const fallbackFont = families.get("*") ?? null;
|
|
453
|
+
return (request, signal) => {
|
|
454
|
+
signal?.throwIfAborted();
|
|
455
|
+
for (const token of request.font.family.split(",")) {
|
|
456
|
+
const matched = families.get(normalizeFamilyToken(token));
|
|
457
|
+
if (matched) {
|
|
458
|
+
const outline = matched.outline(request.character);
|
|
459
|
+
if (outline) return outline;
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
return fallbackFont?.outline(request.character) ?? null;
|
|
463
|
+
};
|
|
464
|
+
}
|
|
465
|
+
export { createTrueTypeOutlineProvider, parseTrueTypeFont };
|
|
466
|
+
|
|
467
|
+
//# sourceMappingURL=truetype.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"truetype.js","names":[],"sources":["../../src/slug/truetype.ts"],"sourcesContent":["import type {\n GlyphRequest,\n WindfoilBoundingBox,\n WindfoilGlyphOutline,\n WindfoilOutlineProvider,\n} from '../types.js'\n\nexport interface TrueTypeFont {\n readonly unitsPerEm: number\n readonly ascent: number\n readonly descent: number\n readonly glyphCount: number\n has(codePoint: number): boolean\n outline(character: string): WindfoilGlyphOutline | null\n outlineForCodePoint(codePoint: number): WindfoilGlyphOutline | null\n}\n\nfunction isArrayBufferLike(value: unknown): value is ArrayBuffer {\n return (\n value instanceof ArrayBuffer || Object.prototype.toString.call(value) === '[object ArrayBuffer]'\n )\n}\n\nfunction toDataView(source: ArrayBuffer | ArrayBufferView): DataView {\n if (isArrayBufferLike(source)) return new DataView(source)\n if (ArrayBuffer.isView(source)) {\n return new DataView(source.buffer, source.byteOffset, source.byteLength)\n }\n throw new TypeError('parseTrueTypeFont: expected an ArrayBuffer or ArrayBufferView')\n}\n\nconst EMPTY_BBOX: WindfoilBoundingBox = Object.freeze([0, 0, 0, 0])\nconst EMPTY_QUADRATICS = new Float32Array(0)\n\nlet ttEnds = new Uint16Array(32)\nlet ttFlags = new Uint8Array(256)\nlet ttXs = new Int32Array(256)\nlet ttYs = new Int32Array(256)\nlet ttExX = new Float64Array(512)\nlet ttExY = new Float64Array(512)\nlet ttExOn = new Uint8Array(512)\nlet ttQuads = new Float32Array(1024)\nlet compX = new Float64Array(256)\nlet compY = new Float64Array(256)\nlet compOn = new Uint8Array(256)\nlet compStarts = new Uint32Array(32)\nlet compLens = new Uint32Array(32)\n\nfunction ensurePointScratch(count: number): void {\n if (count <= ttFlags.length) return\n let size = ttFlags.length\n while (size < count) size *= 2\n ttFlags = new Uint8Array(size)\n ttXs = new Int32Array(size)\n ttYs = new Int32Array(size)\n}\n\nfunction ensureCompositePoints(required: number, currentLen: number): void {\n if (required <= compX.length) return\n let size = compX.length\n while (size < required) size *= 2\n const nx = new Float64Array(size)\n const ny = new Float64Array(size)\n const no = new Uint8Array(size)\n if (currentLen > 0) {\n nx.set(compX.subarray(0, currentLen))\n ny.set(compY.subarray(0, currentLen))\n no.set(compOn.subarray(0, currentLen))\n }\n compX = nx\n compY = ny\n compOn = no\n}\n\nfunction ensureCompositeContours(required: number, currentLen: number): void {\n if (required <= compStarts.length) return\n let size = compStarts.length\n while (size < required) size *= 2\n const ns = new Uint32Array(size)\n const nl = new Uint32Array(size)\n if (currentLen > 0) {\n ns.set(compStarts.subarray(0, currentLen))\n nl.set(compLens.subarray(0, currentLen))\n }\n compStarts = ns\n compLens = nl\n}\n\nfunction ensureExpandedScratch(count: number): void {\n if (count <= ttExX.length) return\n let size = ttExX.length\n while (size < count) size *= 2\n ttExX = new Float64Array(size)\n ttExY = new Float64Array(size)\n ttExOn = new Uint8Array(size)\n}\n\nfunction ensureQuadScratch(required: number, currentLen: number): void {\n if (required <= ttQuads.length) return\n let size = ttQuads.length\n while (size < required) size *= 2\n const next = new Float32Array(size)\n if (currentLen > 0) next.set(ttQuads.subarray(0, currentLen))\n ttQuads = next\n}\n\nfunction emitContourRange(\n xs: ArrayLike<number>,\n ys: ArrayLike<number>,\n onMask: ArrayLike<number>,\n first: number,\n len: number,\n quadLen: number,\n): number {\n if (len < 2) return quadLen\n ensureExpandedScratch(len * 2)\n let exLen = 0\n let firstOn = -1\n for (let i = 0; i < len; i++) {\n const p0 = first + i\n const p1 = first + (i + 1 === len ? 0 : i + 1)\n const x0 = xs[p0]!\n const y0 = ys[p0]!\n const on0 = onMask[p0]! & 1\n if (on0 && firstOn < 0) firstOn = exLen\n ttExX[exLen] = x0\n ttExY[exLen] = y0\n ttExOn[exLen] = on0\n exLen++\n if (!on0 && !(onMask[p1]! & 1)) {\n if (firstOn < 0) firstOn = exLen\n ttExX[exLen] = (x0 + xs[p1]!) * 0.5\n ttExY[exLen] = (y0 + ys[p1]!) * 0.5\n ttExOn[exLen] = 1\n exLen++\n }\n }\n if (firstOn < 0) return quadLen\n ensureQuadScratch(quadLen + exLen * 6, quadLen)\n let curX = ttExX[firstOn]!\n let curY = ttExY[firstOn]!\n let step = 1\n while (step <= exLen) {\n const rawIdx = firstOn + step\n const idx = rawIdx >= exLen ? rawIdx - exLen : rawIdx\n if (ttExOn[idx]!) {\n const px = ttExX[idx]!\n const py = ttExY[idx]!\n ttQuads[quadLen++] = curX\n ttQuads[quadLen++] = curY\n ttQuads[quadLen++] = (curX + px) * 0.5\n ttQuads[quadLen++] = (curY + py) * 0.5\n ttQuads[quadLen++] = px\n ttQuads[quadLen++] = py\n curX = px\n curY = py\n step++\n } else {\n const rawEnd = firstOn + step + 1\n const endIdx = rawEnd >= exLen ? rawEnd - exLen : rawEnd\n const endX = ttExX[endIdx]!\n const endY = ttExY[endIdx]!\n ttQuads[quadLen++] = curX\n ttQuads[quadLen++] = curY\n ttQuads[quadLen++] = ttExX[idx]!\n ttQuads[quadLen++] = ttExY[idx]!\n ttQuads[quadLen++] = endX\n ttQuads[quadLen++] = endY\n curX = endX\n curY = endY\n step += 2\n }\n }\n return quadLen\n}\n\n/**\n * Lightweight runtime TrueType (`.ttf` `glyf` table) outline reader for Slug.\n * Supports Unicode `cmap` formats 4 and 12, simple quadratic contours (including\n * implied midpoints and all-off-curve rings), and offset/affine composite glyphs.\n */\nexport function parseTrueTypeFont(source: ArrayBuffer | ArrayBufferView): TrueTypeFont {\n const view = toDataView(source)\n if (view.byteLength < 12) {\n throw new Error('parseTrueTypeFont: buffer is too short to be a TrueType font')\n }\n const sfntVersion = view.getUint32(0)\n if (sfntVersion === 0x774f4632 || sfntVersion === 0x774f4646) {\n throw new Error(\n 'parseTrueTypeFont: compressed WOFF/WOFF2 buffers are unsupported; pass an uncompressed .ttf buffer or omit outlineProvider to trace loaded webfonts',\n )\n }\n if (sfntVersion === 0x4f54544f) {\n throw new Error(\n 'parseTrueTypeFont: OpenType CFF (.otf) outlines are unsupported; pass a TrueType (.ttf) buffer or omit outlineProvider to trace loaded webfonts',\n )\n }\n\n const numTables = view.getUint16(4)\n const tables = new Map<string, number>()\n for (let i = 0; i < numTables; i++) {\n const at = 12 + i * 16\n if (at + 16 > view.byteLength) break\n const tag = String.fromCharCode(\n view.getUint8(at),\n view.getUint8(at + 1),\n view.getUint8(at + 2),\n view.getUint8(at + 3),\n )\n tables.set(tag, view.getUint32(at + 8))\n }\n\n const table = (tag: string): number => {\n const offset = tables.get(tag)\n if (offset === undefined) throw new Error(`parseTrueTypeFont: missing \"${tag}\" table`)\n return offset\n }\n\n const head = table('head')\n const unitsPerEm = view.getUint16(head + 18)\n const longOffsets = view.getInt16(head + 50) !== 0\n const hhea = table('hhea')\n const ascent = view.getInt16(hhea + 4)\n const descent = view.getInt16(hhea + 6)\n const glyphCount = view.getUint16(table('maxp') + 4)\n const loca = table('loca')\n const glyf = table('glyf')\n const glyphOffset = (index: number): number =>\n longOffsets ? view.getUint32(loca + index * 4) : view.getUint16(loca + index * 2) * 2\n\n const cmap = new Map<number, number>()\n const cmapBase = table('cmap')\n const subtableCount = view.getUint16(cmapBase + 2)\n let chosen = -1\n let chosenFormat = 0\n for (let i = 0; i < subtableCount; i++) {\n const at = cmapBase + 4 + i * 8\n const platform = view.getUint16(at)\n const encoding = view.getUint16(at + 2)\n const offset = cmapBase + view.getUint32(at + 4)\n const format = view.getUint16(offset)\n const unicode = platform === 0 || (platform === 3 && (encoding === 1 || encoding === 10))\n if (unicode && (format === 12 || (format === 4 && chosenFormat !== 12))) {\n chosen = offset\n chosenFormat = format\n }\n }\n if (chosen < 0) throw new Error('parseTrueTypeFont: font has no Unicode cmap subtable')\n\n if (chosenFormat === 4) {\n const segments = view.getUint16(chosen + 6) >> 1\n const ends = chosen + 14\n const starts = ends + segments * 2 + 2\n const deltas = starts + segments * 2\n const ranges = deltas + segments * 2\n for (let segment = 0; segment < segments; segment++) {\n const end = view.getUint16(ends + segment * 2)\n const start = view.getUint16(starts + segment * 2)\n const delta = view.getInt16(deltas + segment * 2)\n const rangeOffset = view.getUint16(ranges + segment * 2)\n for (let code = start; code <= end && code !== 0xffff; code++) {\n let glyph = code\n if (rangeOffset !== 0) {\n glyph = view.getUint16(ranges + segment * 2 + rangeOffset + (code - start) * 2)\n if (glyph === 0) continue\n }\n glyph = (glyph + delta) & 0xffff\n if (glyph !== 0) cmap.set(code, glyph)\n }\n }\n } else {\n const groups = view.getUint32(chosen + 12)\n for (let group = 0; group < groups; group++) {\n const at = chosen + 16 + group * 12\n const start = view.getUint32(at)\n const end = view.getUint32(at + 4)\n const first = view.getUint32(at + 8)\n for (let code = start; code <= end; code++) {\n const glyph = first + code - start\n if (glyph !== 0) cmap.set(code, glyph)\n }\n }\n }\n\n function readSimplePoints(at: number, contourCount: number): number {\n if (contourCount === 0) return 0\n if (contourCount > ttEnds.length) {\n let size = ttEnds.length\n while (size < contourCount) size *= 2\n ttEnds = new Uint16Array(size)\n }\n for (let c = 0; c < contourCount; c++) {\n ttEnds[c] = view.getUint16(at + 10 + c * 2)\n }\n const pointCount = ttEnds[contourCount - 1]! + 1\n let cursor = at + 10 + contourCount * 2\n cursor += 2 + view.getUint16(cursor)\n ensurePointScratch(pointCount)\n let fIdx = 0\n while (fIdx < pointCount) {\n const flag = view.getUint8(cursor++)\n ttFlags[fIdx++] = flag\n if (flag & 8) {\n const repeat = view.getUint8(cursor++)\n const end = Math.min(pointCount, fIdx + repeat)\n while (fIdx < end) ttFlags[fIdx++] = flag\n }\n }\n let vx = 0\n for (let i = 0; i < pointCount; i++) {\n const flag = ttFlags[i]!\n if (flag & 2) {\n const delta = view.getUint8(cursor++)\n vx += flag & 16 ? delta : -delta\n } else if (!(flag & 16)) {\n vx += view.getInt16(cursor)\n cursor += 2\n }\n ttXs[i] = vx\n }\n let vy = 0\n for (let i = 0; i < pointCount; i++) {\n const flag = ttFlags[i]!\n if (flag & 4) {\n const delta = view.getUint8(cursor++)\n vy += flag & 32 ? delta : -delta\n } else if (!(flag & 32)) {\n vy += view.getInt16(cursor)\n cursor += 2\n }\n ttYs[i] = vy\n }\n return pointCount\n }\n\n function decodeSimpleGlyph(\n at: number,\n contourCount: number,\n bbox: WindfoilBoundingBox,\n ): WindfoilGlyphOutline {\n if (contourCount === 0) {\n return Object.freeze({\n unitsPerEm,\n ascent,\n descent,\n bbox,\n quadratics: EMPTY_QUADRATICS,\n })\n }\n readSimplePoints(at, contourCount)\n let quadLen = 0\n let first = 0\n for (let c = 0; c < contourCount; c++) {\n const last = ttEnds[c]!\n quadLen = emitContourRange(ttXs, ttYs, ttFlags, first, last - first + 1, quadLen)\n first = last + 1\n }\n return Object.freeze({\n unitsPerEm,\n ascent,\n descent,\n bbox,\n quadratics: ttQuads.slice(0, quadLen),\n })\n }\n\n function appendGlyphContours(\n index: number,\n a: number,\n b: number,\n c: number,\n d: number,\n dx: number,\n dy: number,\n depth: number,\n state: { pointLen: number; contourLen: number },\n ): boolean {\n if (index < 0 || index >= glyphCount || depth > 8) return false\n const start = glyphOffset(index)\n if (glyphOffset(index + 1) <= start) return true\n const at = glyf + start\n const contourCount = view.getInt16(at)\n if (contourCount >= 0) {\n const pointCount = readSimplePoints(at, contourCount)\n if (pointCount === 0) return true\n ensureCompositePoints(state.pointLen + pointCount, state.pointLen)\n ensureCompositeContours(state.contourLen + contourCount, state.contourLen)\n const ptBase = state.pointLen\n for (let p = 0; p < pointCount; p++) {\n const x = ttXs[p]!\n const y = ttYs[p]!\n compX[ptBase + p] = a * x + c * y + dx\n compY[ptBase + p] = b * x + d * y + dy\n compOn[ptBase + p] = ttFlags[p]! & 1\n }\n let first = 0\n for (let k = 0; k < contourCount; k++) {\n const last = ttEnds[k]!\n compStarts[state.contourLen] = ptBase + first\n compLens[state.contourLen] = last - first + 1\n state.contourLen++\n first = last + 1\n }\n state.pointLen = ptBase + pointCount\n return true\n }\n\n let cursor = at + 10\n for (;;) {\n const flags = view.getUint16(cursor)\n const component = view.getUint16(cursor + 2)\n cursor += 4\n if (!(flags & 2)) return false\n const cdx = flags & 1 ? view.getInt16(cursor) : view.getInt8(cursor)\n const cdy = flags & 1 ? view.getInt16(cursor + 2) : view.getInt8(cursor + 1)\n cursor += flags & 1 ? 4 : 2\n let ca = 1,\n cb = 0,\n cc = 0,\n cd = 1\n if (flags & 8) {\n ca = cd = view.getInt16(cursor) / 16384\n cursor += 2\n } else if (flags & 0x40) {\n ca = view.getInt16(cursor) / 16384\n cd = view.getInt16(cursor + 2) / 16384\n cursor += 4\n } else if (flags & 0x80) {\n ca = view.getInt16(cursor) / 16384\n cb = view.getInt16(cursor + 2) / 16384\n cc = view.getInt16(cursor + 4) / 16384\n cd = view.getInt16(cursor + 6) / 16384\n cursor += 8\n }\n const ok = appendGlyphContours(\n component,\n a * ca + c * cb,\n b * ca + d * cb,\n a * cc + c * cd,\n b * cc + d * cd,\n a * cdx + c * cdy + dx,\n b * cdx + d * cdy + dy,\n depth + 1,\n state,\n )\n if (!ok) return false\n if (!(flags & 0x20)) return true\n }\n }\n\n function decodeCompositeGlyph(at: number, index: number): WindfoilGlyphOutline | null {\n const bbox: WindfoilBoundingBox = Object.freeze([\n view.getInt16(at + 2),\n view.getInt16(at + 4),\n view.getInt16(at + 6),\n view.getInt16(at + 8),\n ])\n const state = { pointLen: 0, contourLen: 0 }\n if (!appendGlyphContours(index, 1, 0, 0, 1, 0, 0, 0, state)) return null\n let quadLen = 0\n for (let k = 0; k < state.contourLen; k++) {\n quadLen = emitContourRange(compX, compY, compOn, compStarts[k]!, compLens[k]!, quadLen)\n }\n return Object.freeze({\n unitsPerEm,\n ascent,\n descent,\n bbox,\n quadratics: ttQuads.slice(0, quadLen),\n })\n }\n\n const cache = new Map<number, WindfoilGlyphOutline | null>()\n const outlineForCodePoint = (codePoint: number): WindfoilGlyphOutline | null => {\n const index = cmap.get(codePoint)\n if (index === undefined) return null\n let entry = cache.get(index)\n if (entry === undefined && !cache.has(index)) {\n if (index < 0 || index >= glyphCount) {\n entry = null\n } else {\n const start = glyphOffset(index)\n if (glyphOffset(index + 1) <= start) {\n entry = Object.freeze({\n unitsPerEm,\n ascent,\n descent,\n bbox: EMPTY_BBOX,\n quadratics: EMPTY_QUADRATICS,\n })\n } else {\n const at = glyf + start\n const contourCount = view.getInt16(at)\n if (contourCount >= 0) {\n const bbox: WindfoilBoundingBox = Object.freeze([\n view.getInt16(at + 2),\n view.getInt16(at + 4),\n view.getInt16(at + 6),\n view.getInt16(at + 8),\n ])\n entry = decodeSimpleGlyph(at, contourCount, bbox)\n } else {\n entry = decodeCompositeGlyph(at, index)\n }\n }\n }\n cache.set(index, entry)\n }\n return entry ?? null\n }\n return {\n unitsPerEm,\n ascent,\n descent,\n glyphCount,\n has(codePoint: number): boolean {\n return cmap.has(codePoint)\n },\n outlineForCodePoint,\n outline(character: string): WindfoilGlyphOutline | null {\n const code = character.codePointAt(0)\n if (code === undefined || character.length !== (code > 0xffff ? 2 : 1)) return null\n return outlineForCodePoint(code)\n },\n }\n}\n\nexport type TrueTypeFontSource =\n | ArrayBuffer\n | ArrayBufferView\n | TrueTypeFont\n | ReadonlyMap<string, ArrayBuffer | ArrayBufferView | TrueTypeFont>\n | Readonly<Record<string, ArrayBuffer | ArrayBufferView | TrueTypeFont>>\n\nfunction asParsedFont(entry: ArrayBuffer | ArrayBufferView | TrueTypeFont): TrueTypeFont {\n if ('outline' in entry && typeof entry.outline === 'function') return entry\n return parseTrueTypeFont(entry as ArrayBuffer | ArrayBufferView)\n}\n\nfunction normalizeFamilyToken(family: string): string {\n return family\n .trim()\n .replace(/^['\"]|['\"]$/g, '')\n .toLowerCase()\n}\n\n/**\n * Creates a `WindfoilOutlineProvider` from a single `.ttf` buffer/`TrueTypeFont` or a family-keyed\n * map/object of `.ttf` buffers (with optional `'*'` fallback key).\n */\nexport function createTrueTypeOutlineProvider(source: TrueTypeFontSource): WindfoilOutlineProvider {\n if (\n isArrayBufferLike(source) ||\n ArrayBuffer.isView(source) ||\n ('outline' in source && typeof source.outline === 'function')\n ) {\n const font = asParsedFont(source as ArrayBuffer | ArrayBufferView | TrueTypeFont)\n return (request: GlyphRequest, signal?: AbortSignal) => {\n signal?.throwIfAborted()\n return font.outline(request.character)\n }\n }\n\n const families = new Map<string, TrueTypeFont>()\n const entries =\n source instanceof Map\n ? (source as ReadonlyMap<string, ArrayBuffer | ArrayBufferView | TrueTypeFont>).entries()\n : Object.entries(\n source as Readonly<Record<string, ArrayBuffer | ArrayBufferView | TrueTypeFont>>,\n )\n for (const [key, value] of entries) {\n families.set(key === '*' ? '*' : normalizeFamilyToken(key), asParsedFont(value))\n }\n const fallbackFont = families.get('*') ?? null\n\n return (request: GlyphRequest, signal?: AbortSignal) => {\n signal?.throwIfAborted()\n for (const token of request.font.family.split(',')) {\n const matched = families.get(normalizeFamilyToken(token))\n if (matched) {\n const outline = matched.outline(request.character)\n if (outline) return outline\n }\n }\n return fallbackFont?.outline(request.character) ?? null\n }\n}\n"],"mappings":";AAiBA,SAAS,kBAAkB,OAAsC;CAC/D,OACE,iBAAiB,eAAe,OAAO,UAAU,SAAS,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