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.
Files changed (200) hide show
  1. package/README.md +267 -962
  2. package/THIRD_PARTY_NOTICES.md +3 -0
  3. package/dist/assets/{cpuSdf.worker-Du9o8q4p.js → cpuSdf.worker--X1Qpmdp.js} +148 -57
  4. package/dist/assets/cpuSdf.worker--X1Qpmdp.js.map +1 -0
  5. package/dist/atlas/appendAtlas.js +69 -26
  6. package/dist/atlas/appendAtlas.js.map +1 -1
  7. package/dist/atlas/buildAtlas.js +5 -15
  8. package/dist/atlas/buildAtlas.js.map +1 -1
  9. package/dist/atlas/cpuAtlas.d.ts +4 -1
  10. package/dist/atlas/cpuAtlas.js +8 -6
  11. package/dist/atlas/cpuAtlas.js.map +1 -1
  12. package/dist/atlas/cpuSdf.js +164 -50
  13. package/dist/atlas/cpuSdf.js.map +1 -1
  14. package/dist/atlas/cpuWorker.d.ts +5 -3
  15. package/dist/atlas/cpuWorker.js +119 -12
  16. package/dist/atlas/cpuWorker.js.map +1 -1
  17. package/dist/atlas/gpuAtlas.d.ts +7 -6
  18. package/dist/atlas/gpuAtlas.js +206 -247
  19. package/dist/atlas/gpuAtlas.js.map +1 -1
  20. package/dist/atlas/gpuCommon.d.ts +135 -0
  21. package/dist/atlas/gpuCommon.js +223 -0
  22. package/dist/atlas/gpuCommon.js.map +1 -0
  23. package/dist/atlas/jfaWgsl.js +59 -125
  24. package/dist/atlas/jfaWgsl.js.map +1 -1
  25. package/dist/atlas/rasterize.d.ts +2 -0
  26. package/dist/atlas/rasterize.js +104 -144
  27. package/dist/atlas/rasterize.js.map +1 -1
  28. package/dist/atlas/shapeRaster.js +2 -1
  29. package/dist/atlas/shapeRaster.js.map +1 -1
  30. package/dist/atlas/vanillaBounds.d.ts +64 -0
  31. package/dist/atlas/vanillaBounds.js +42 -0
  32. package/dist/atlas/vanillaBounds.js.map +1 -0
  33. package/dist/atlas/vanillaCore.d.ts +100 -0
  34. package/dist/atlas/vanillaCore.js +1012 -0
  35. package/dist/atlas/vanillaCore.js.map +1 -0
  36. package/dist/atlas/vanillaCpuAtlas.d.ts +9 -0
  37. package/dist/atlas/vanillaCpuAtlas.js +87 -0
  38. package/dist/atlas/vanillaCpuAtlas.js.map +1 -0
  39. package/dist/atlas/vanillaExtras.d.ts +8 -0
  40. package/dist/atlas/vanillaExtras.js +166 -0
  41. package/dist/atlas/vanillaExtras.js.map +1 -0
  42. package/dist/atlas/vanillaGpuHelpers.d.ts +232 -0
  43. package/dist/atlas/vanillaGpuHelpers.js +119 -0
  44. package/dist/atlas/vanillaGpuHelpers.js.map +1 -0
  45. package/dist/dom/DomSdf.js +263 -272
  46. package/dist/dom/DomSdf.js.map +1 -1
  47. package/dist/dom/DomSlug.d.ts +26 -0
  48. package/dist/dom/DomSlug.js +564 -0
  49. package/dist/dom/DomSlug.js.map +1 -0
  50. package/dist/dom/SlugText.d.ts +18 -0
  51. package/dist/dom/SlugText.js +94 -0
  52. package/dist/dom/SlugText.js.map +1 -0
  53. package/dist/dom/Text.js +4 -67
  54. package/dist/dom/Text.js.map +1 -1
  55. package/dist/dom/domAnalytic.d.ts +54 -0
  56. package/dist/dom/domAnalytic.js +282 -0
  57. package/dist/dom/domAnalytic.js.map +1 -0
  58. package/dist/dom/domExtras.d.ts +27 -0
  59. package/dist/dom/domExtras.js +137 -0
  60. package/dist/dom/domExtras.js.map +1 -0
  61. package/dist/dom/fontCanvas.d.ts +2 -0
  62. package/dist/dom/fontCanvas.js +119 -0
  63. package/dist/dom/fontCanvas.js.map +1 -0
  64. package/dist/dom/layoutSignature.js +156 -27
  65. package/dist/dom/layoutSignature.js.map +1 -1
  66. package/dist/dom/pretextLayout.js +55 -13
  67. package/dist/dom/pretextLayout.js.map +1 -1
  68. package/dist/dom/snapshot.js +563 -243
  69. package/dist/dom/snapshot.js.map +1 -1
  70. package/dist/dom/svgCapture.d.ts +8 -1
  71. package/dist/dom/svgCapture.js +75 -1
  72. package/dist/dom/svgCapture.js.map +1 -1
  73. package/dist/dom/textHost.d.ts +11 -0
  74. package/dist/dom/textHost.js +68 -0
  75. package/dist/dom/textHost.js.map +1 -0
  76. package/dist/dom/tone.js +76 -36
  77. package/dist/dom/tone.js.map +1 -1
  78. package/dist/index.js +4 -3
  79. package/dist/slug/SlugMaterial.d.ts +13 -4
  80. package/dist/slug/SlugMaterial.js +82 -12
  81. package/dist/slug/SlugMaterial.js.map +1 -1
  82. package/dist/slug/coverage.d.ts +17 -13
  83. package/dist/slug/coverage.js +195 -222
  84. package/dist/slug/coverage.js.map +1 -1
  85. package/dist/slug/preprocessCore.d.ts +6 -3
  86. package/dist/slug/preprocessCore.js +149 -95
  87. package/dist/slug/preprocessCore.js.map +1 -1
  88. package/dist/slug/runtime.d.ts +1 -0
  89. package/dist/slug/runtime.js +94 -46
  90. package/dist/slug/runtime.js.map +1 -1
  91. package/dist/slug/standaloneRuntime.d.ts +40 -0
  92. package/dist/slug/standaloneRuntime.js +175 -0
  93. package/dist/slug/standaloneRuntime.js.map +1 -0
  94. package/dist/slug/truetype.d.ts +22 -0
  95. package/dist/slug/truetype.js +467 -0
  96. package/dist/slug/truetype.js.map +1 -0
  97. package/dist/slug/vanillaCore.d.ts +340 -0
  98. package/dist/slug/vanillaCore.js +1621 -0
  99. package/dist/slug/vanillaCore.js.map +1 -0
  100. package/dist/slug-vanilla.d.ts +13 -0
  101. package/dist/slug-vanilla.js +13 -0
  102. package/dist/slug.d.ts +21 -0
  103. package/dist/slug.js +19 -0
  104. package/dist/text/GlyphTextMaterial.d.ts +11 -11
  105. package/dist/text/GlyphTextMaterial.js +102 -33
  106. package/dist/text/GlyphTextMaterial.js.map +1 -1
  107. package/dist/text/SdfTextMaterial.d.ts +5 -4
  108. package/dist/text/SdfTextMaterial.js +29 -9
  109. package/dist/text/SdfTextMaterial.js.map +1 -1
  110. package/dist/text/decorations.js +36 -19
  111. package/dist/text/decorations.js.map +1 -1
  112. package/dist/text/geometry.d.ts +3 -22
  113. package/dist/text/geometryUtils.d.ts +11 -1
  114. package/dist/text/geometryUtils.js +22 -1
  115. package/dist/text/geometryUtils.js.map +1 -1
  116. package/dist/text/glyphGeometry.d.ts +9 -0
  117. package/dist/text/glyphGeometry.js +353 -0
  118. package/dist/text/glyphGeometry.js.map +1 -0
  119. package/dist/text/index.d.ts +2 -1
  120. package/dist/text/rectGeometry.d.ts +13 -0
  121. package/dist/text/rectGeometry.js +97 -0
  122. package/dist/text/rectGeometry.js.map +1 -0
  123. package/dist/text/reflow.d.ts +18 -1
  124. package/dist/text/reflow.js +108 -38
  125. package/dist/text/reflow.js.map +1 -1
  126. package/dist/text/snap.d.ts +1 -0
  127. package/dist/text/snap.js +26 -0
  128. package/dist/text/snap.js.map +1 -0
  129. package/dist/types.d.ts +63 -14
  130. package/dist/vanilla.d.ts +13 -360
  131. package/dist/vanilla.js +8 -1402
  132. package/dist/windfoil/WindfoilMaterial.d.ts +2 -1
  133. package/dist/windfoil/WindfoilMaterial.js +8 -1
  134. package/dist/windfoil/WindfoilMaterial.js.map +1 -1
  135. package/dist/windfoil/abortable.d.ts +2 -0
  136. package/dist/windfoil/abortable.js +26 -0
  137. package/dist/windfoil/abortable.js.map +1 -0
  138. package/dist/windfoil/color.js +2 -1
  139. package/dist/windfoil/color.js.map +1 -1
  140. package/dist/windfoil/coverage.d.ts +3 -20
  141. package/dist/windfoil/coverage.js +7 -20
  142. package/dist/windfoil/coverage.js.map +1 -1
  143. package/dist/windfoil/emoji.js +1 -1
  144. package/dist/windfoil/emoji.js.map +1 -1
  145. package/dist/windfoil/emojiMetrics.js +1 -1
  146. package/dist/windfoil/emojiMetrics.js.map +1 -1
  147. package/dist/windfoil/geometry.d.ts +2 -2
  148. package/dist/windfoil/geometry.js +204 -64
  149. package/dist/windfoil/geometry.js.map +1 -1
  150. package/dist/windfoil/layerGrid.js +14 -10
  151. package/dist/windfoil/layerGrid.js.map +1 -1
  152. package/dist/windfoil/layerNormalization.d.ts +1 -1
  153. package/dist/windfoil/layerNormalization.js +1 -1
  154. package/dist/windfoil/layerNormalization.js.map +1 -1
  155. package/dist/windfoil/mixed.d.ts +1 -0
  156. package/dist/windfoil/mixed.js +44 -25
  157. package/dist/windfoil/mixed.js.map +1 -1
  158. package/dist/windfoil/outlineValidation.d.ts +86 -0
  159. package/dist/windfoil/outlineValidation.js +65 -0
  160. package/dist/windfoil/outlineValidation.js.map +1 -0
  161. package/dist/windfoil/preprocess.js +3 -2
  162. package/dist/windfoil/preprocess.js.map +1 -1
  163. package/dist/windfoil/preprocessCore.d.ts +5 -85
  164. package/dist/windfoil/preprocessCore.js +218 -209
  165. package/dist/windfoil/preprocessCore.js.map +1 -1
  166. package/dist/windfoil/requests.js +1 -1
  167. package/dist/windfoil/requests.js.map +1 -1
  168. package/dist/windfoil/runtime.d.ts +5 -2
  169. package/dist/windfoil/runtime.js +63 -40
  170. package/dist/windfoil/runtime.js.map +1 -1
  171. package/dist/windfoil/shapeResources.js +2 -1
  172. package/dist/windfoil/shapeResources.js.map +1 -1
  173. package/dist/windfoil/shapes.js +1 -1
  174. package/dist/windfoil/skirt.d.ts +22 -0
  175. package/dist/windfoil/skirt.js +20 -0
  176. package/dist/windfoil/skirt.js.map +1 -0
  177. package/dist/windfoil/storage.d.ts +62 -4
  178. package/dist/windfoil/storage.js +143 -28
  179. package/dist/windfoil/storage.js.map +1 -1
  180. package/dist/windfoil/trace/contours.d.ts +3 -3
  181. package/dist/windfoil/trace/contours.js +228 -137
  182. package/dist/windfoil/trace/contours.js.map +1 -1
  183. package/dist/windfoil/trace/fit.d.ts +3 -7
  184. package/dist/windfoil/trace/fit.js +668 -376
  185. package/dist/windfoil/trace/fit.js.map +1 -1
  186. package/dist/windfoil/trace/outline.js +60 -35
  187. package/dist/windfoil/trace/outline.js.map +1 -1
  188. package/dist/windfoil/trace/types.d.ts +15 -3
  189. package/dist/windfoil/tracedOutlines.d.ts +37 -1
  190. package/dist/windfoil/tracedOutlines.js +228 -64
  191. package/dist/windfoil/tracedOutlines.js.map +1 -1
  192. package/package.json +60 -11
  193. package/skills/ultra-text/SKILL.md +114 -0
  194. package/skills/ultra-text/references/frameworks.md +43 -0
  195. package/skills/ultra-text/references/three-tsl.md +78 -0
  196. package/skills/ultra-text/references/vanilla-webgpu.md +96 -0
  197. package/dist/assets/cpuSdf.worker-Du9o8q4p.js.map +0 -1
  198. package/dist/text/geometry.js +0 -348
  199. package/dist/text/geometry.js.map +0 -1
  200. package/dist/vanilla.js.map +0 -1
@@ -1,56 +1,8 @@
1
- var WINDFOIL_MAX_LAYERS = 1024;
1
+ import { checkFloat32, float32Bits, readBox, readFiniteFloat32, readFlatCoordinates } from "./outlineValidation.js";
2
2
  var FLOAT32_FAR = 3e38;
3
3
  function throwIfAborted(signal) {
4
4
  if (signal?.aborted) throw signal.reason ?? new DOMException("Windfoil preprocessing was aborted", "AbortError");
5
5
  }
6
- function readFiniteFloat32(value, label) {
7
- if (typeof value !== "number" || !Number.isFinite(value)) throw new TypeError(`${label} must be a finite number`);
8
- if (!Number.isFinite(Math.fround(value))) throw new RangeError(`${label} must be representable as a finite float32`);
9
- return value;
10
- }
11
- function readFlatNumbers(value, label, expectedLength) {
12
- if (typeof value !== "object" || value === null || !("length" in value)) throw new TypeError(`${label} must be an array-like list of numbers`);
13
- const length = value.length;
14
- if (!Number.isSafeInteger(length) || length < 0) throw new RangeError(`${label}.length must be a non-negative safe integer`);
15
- if (expectedLength !== void 0 && length !== expectedLength) throw new RangeError(`${label} must contain exactly ${expectedLength} numbers`);
16
- const source = value;
17
- const result = new Array(length);
18
- for (let index = 0; index < result.length; index++) {
19
- const item = source[index];
20
- result[index] = typeof item === "number" && Number.isFinite(item) && Number.isFinite(Math.fround(item)) ? item : readFiniteFloat32(item, `${label}[${index}]`);
21
- }
22
- return result;
23
- }
24
- function readFlatCoordinates(value, label) {
25
- if (value instanceof Float32Array) {
26
- for (let index = 0; index < value.length; index++) if (!Number.isFinite(value[index])) readFiniteFloat32(value[index], `${label}[${index}]`);
27
- return value;
28
- }
29
- if (value instanceof Float64Array) {
30
- for (let index = 0; index < value.length; index++) if (!Number.isFinite(Math.fround(value[index]))) readFiniteFloat32(value[index], `${label}[${index}]`);
31
- return value;
32
- }
33
- if (Array.isArray(value)) {
34
- const arr = value;
35
- const len = arr.length;
36
- for (let index = 0; index < len; index++) {
37
- const item = arr[index];
38
- if (typeof item !== "number" || !Number.isFinite(Math.fround(item))) readFiniteFloat32(item, `${label}[${index}]`);
39
- }
40
- return arr;
41
- }
42
- return readFlatNumbers(value, label);
43
- }
44
- function readBox(value, label) {
45
- const v = Array.isArray(value) && value.length === 4 && typeof value[0] === "number" && typeof value[1] === "number" && typeof value[2] === "number" && typeof value[3] === "number" && Number.isFinite(Math.fround(value[0]) + Math.fround(value[1]) + Math.fround(value[2]) + Math.fround(value[3])) ? value : readFlatNumbers(value, label, 4);
46
- if (v[0] > v[2] || v[1] > v[3]) throw new RangeError(`${label} minima must not exceed its maxima`);
47
- return [
48
- v[0],
49
- v[1],
50
- v[2],
51
- v[3]
52
- ];
53
- }
54
6
  function normalizeOutline(value, label, normalizeLayers) {
55
7
  if (typeof value !== "object" || value === null) throw new TypeError(`${label} must be an object`);
56
8
  const outline = value;
@@ -107,25 +59,23 @@ function equalValues(left, right) {
107
59
  const a = left, b = right, keys = Object.keys(a).filter((key) => key !== "paintLabel" && a[key] !== void 0), otherKeys = Object.keys(b).filter((key) => key !== "paintLabel" && b[key] !== void 0);
108
60
  return keys.length === otherKeys.length && keys.every((key) => equalValues(a[key], b[key]));
109
61
  }
62
+ function sameNums(a, b) {
63
+ if (a.length !== b.length) return false;
64
+ for (let i = 0; i < a.length; i++) if (a[i] !== b[i]) return false;
65
+ return true;
66
+ }
110
67
  function layersEqual(left, right) {
111
68
  if (left === right) return true;
112
69
  if (left?.length !== right?.length) return false;
113
70
  if (!left || !right) return true;
114
71
  for (let i = 0; i < left.length; i++) {
115
72
  const a = left[i], b = right[i];
116
- if (a.paintKind !== b.paintKind || a.bbox[0] !== b.bbox[0] || a.bbox[1] !== b.bbox[1] || a.bbox[2] !== b.bbox[2] || a.bbox[3] !== b.bbox[3] || a.rgba[0] !== b.rgba[0] || a.rgba[1] !== b.rgba[1] || a.rgba[2] !== b.rgba[2] || a.rgba[3] !== b.rgba[3] || a.quadratics.length !== b.quadratics.length) return false;
117
- for (let j = 0; j < a.quadratics.length; j++) if (a.quadratics[j] !== b.quadratics[j]) return false;
118
- if (!equalValues(a.paint, b.paint)) return false;
73
+ if (a.paintKind !== b.paintKind || !sameNums(a.bbox, b.bbox) || !sameNums(a.rgba, b.rgba) || !sameNums(a.quadratics, b.quadratics) || !equalValues(a.paint, b.paint)) return false;
119
74
  }
120
75
  return true;
121
76
  }
122
77
  function outlinesEqual(left, right) {
123
- if (left === right) return true;
124
- if (left.unitsPerEm !== right.unitsPerEm || left.ascent !== right.ascent || left.descent !== right.descent) return false;
125
- for (let index = 0; index < left.bbox.length; index++) if (left.bbox[index] !== right.bbox[index]) return false;
126
- if (left.quadratics.length !== right.quadratics.length) return false;
127
- for (let index = 0; index < left.quadratics.length; index++) if (left.quadratics[index] !== right.quadratics[index]) return false;
128
- return layersEqual(left.layers, right.layers) && equalValues(left.clipBox, right.clipBox);
78
+ return left === right || left.unitsPerEm === right.unitsPerEm && left.ascent === right.ascent && left.descent === right.descent && sameNums(left.bbox, right.bbox) && sameNums(left.quadratics, right.quadratics) && layersEqual(left.layers, right.layers) && equalValues(left.clipBox, right.clipBox);
129
79
  }
130
80
  function extremumParameter(start, control, end) {
131
81
  const secondDifference = start - 2 * control + end;
@@ -164,18 +114,8 @@ function splitOutline(quadratics, signal) {
164
114
  for (let offset = 0; offset < quadLen; offset += 6) {
165
115
  if ((offset & 1023) === 0 && offset % 1536 === 0) throwIfAborted(signal);
166
116
  const x0 = quadratics[offset], y0 = quadratics[offset + 1], controlX = quadratics[offset + 2], controlY = quadratics[offset + 3], x1 = quadratics[offset + 4], y1 = quadratics[offset + 5];
167
- if (controlX >= (x0 < x1 ? x0 : x1) && controlX <= (x0 > x1 ? x0 : x1) && controlY >= (y0 < y1 ? y0 : y1) && controlY <= (y0 > y1 ? y0 : y1)) {
168
- output[outLen] = x0;
169
- output[outLen + 1] = y0;
170
- output[outLen + 2] = controlX;
171
- output[outLen + 3] = controlY;
172
- output[outLen + 4] = x1;
173
- output[outLen + 5] = y1;
174
- outLen += 6;
175
- continue;
176
- }
177
- const xExtremum = extremumParameter(x0, controlX, x1);
178
- const yExtremum = extremumParameter(y0, controlY, y1);
117
+ const xExtremum = controlX >= (x0 < x1 ? x0 : x1) && controlX <= (x0 > x1 ? x0 : x1) ? void 0 : extremumParameter(x0, controlX, x1);
118
+ const yExtremum = controlY >= (y0 < y1 ? y0 : y1) && controlY <= (y0 > y1 ? y0 : y1) ? void 0 : extremumParameter(y0, controlY, y1);
179
119
  if (xExtremum === void 0 && yExtremum === void 0) {
180
120
  output[outLen] = x0;
181
121
  output[outLen + 1] = y0;
@@ -231,10 +171,10 @@ function monotoneRoot(a, hy, start, end, value, rising) {
231
171
  const root = -c / den;
232
172
  return root <= 0 ? 0 : root >= 1 ? 1 : root;
233
173
  }
234
- function bandWindingArea(pieces, bucket, xReference, bandMin, bandMax) {
174
+ function bandWindingArea(pieces, bucketData, bucketOffset, bucketLen, xReference, bandMin, bandMax) {
235
175
  let area = 0;
236
- for (let i = 0, n = bucket.length; i < n; i++) {
237
- const offset = bucket[i] * 6;
176
+ for (let i = 0; i < bucketLen; i++) {
177
+ const offset = bucketData[bucketOffset + i] * 6;
238
178
  const y0 = pieces[offset + 1];
239
179
  const y1 = pieces[offset + 5];
240
180
  if (y0 === y1) continue;
@@ -271,13 +211,6 @@ function bandWindingArea(pieces, bucket, xReference, bandMin, bandMax) {
271
211
  }
272
212
  return area;
273
213
  }
274
- var scratchF32 = /* @__PURE__ */ new Float32Array(1);
275
- var scratchU32 = new Uint32Array(scratchF32.buffer);
276
- function float32Bits(value, label) {
277
- scratchF32[0] = value;
278
- if (!Number.isFinite(scratchF32[0])) throw new RangeError(`${label} must be representable as a finite float32`);
279
- return scratchU32[0];
280
- }
281
214
  /**
282
215
  * The x at which as many band pieces start left of a fragment as end right of it.
283
216
  *
@@ -305,11 +238,19 @@ function assertUint32(value, label) {
305
238
  var scratchPieceXMin = /* @__PURE__ */ new Float64Array(256);
306
239
  var scratchPieceXMax = /* @__PURE__ */ new Float64Array(256);
307
240
  var scratchPieceHasYSpan = /* @__PURE__ */ new Uint8Array(256);
241
+ var scratchPieceFirstBand = /* @__PURE__ */ new Uint8Array(256);
242
+ var scratchPieceLastBand = /* @__PURE__ */ new Uint8Array(256);
308
243
  var scratchGather = /* @__PURE__ */ new Int32Array(256);
309
244
  var scratchByXMin = /* @__PURE__ */ new Int32Array(256);
310
245
  var scratchCurves = /* @__PURE__ */ new Float32Array(0);
311
246
  var scratchRows = /* @__PURE__ */ new Uint32Array(0);
312
- var scratchBuckets = Array.from({ length: 64 }, () => []);
247
+ var scratchBucketData = /* @__PURE__ */ new Int32Array(512);
248
+ var scratchBucketCounts = /* @__PURE__ */ new Int32Array(64);
249
+ var scratchBucketOffsets = /* @__PURE__ */ new Int32Array(65);
250
+ var scratchBandClipped = /* @__PURE__ */ new Float64Array(256);
251
+ var scratchBandSource = /* @__PURE__ */ new Int32Array(256);
252
+ var scratchBandXMin = /* @__PURE__ */ new Float64Array(256);
253
+ var scratchBandXMax = /* @__PURE__ */ new Float64Array(256);
313
254
  function ensureCurveCapacity(required, currentLen) {
314
255
  if (required <= scratchCurves.length) return scratchCurves;
315
256
  const next = new Float32Array(Math.max(scratchCurves.length * 2, required, 1024));
@@ -324,23 +265,30 @@ function ensureRowCapacity(required, currentLen) {
324
265
  scratchRows = next;
325
266
  return next;
326
267
  }
327
- function fileBands(pieces, pieceCount, y0, y1, packed, targetPiecesPerBand, signal) {
268
+ function fileBands(pieces, pieceCount, y0, y1, clipScale, packed, targetPiecesPerBand, signal) {
328
269
  const bandCount = chooseBandCount(pieceCount, targetPiecesPerBand);
329
270
  const invH = bandCount > 1 && y1 > y0 ? bandCount / (y1 - y0) : 0;
330
- const buckets = scratchBuckets;
331
- for (let band = 0; band < bandCount; band++) buckets[band].length = 0;
271
+ scratchBucketCounts.fill(0, 0, bandCount);
332
272
  if (pieceCount > scratchPieceXMin.length) {
333
273
  const cap = Math.max(scratchPieceXMin.length * 2, pieceCount);
334
274
  scratchPieceXMin = new Float64Array(cap);
335
275
  scratchPieceXMax = new Float64Array(cap);
336
276
  scratchPieceHasYSpan = new Uint8Array(cap);
277
+ scratchPieceFirstBand = new Uint8Array(cap);
278
+ scratchPieceLastBand = new Uint8Array(cap);
337
279
  scratchGather = new Int32Array(cap);
338
280
  scratchByXMin = new Int32Array(cap);
281
+ scratchBandSource = new Int32Array(cap);
282
+ scratchBandXMin = new Float64Array(cap);
283
+ scratchBandXMax = new Float64Array(cap);
339
284
  }
340
285
  const pieceXMin = scratchPieceXMin;
341
286
  const pieceXMax = scratchPieceXMax;
342
287
  const pieceHasYSpan = scratchPieceHasYSpan;
288
+ const pieceFirstBand = scratchPieceFirstBand;
289
+ const pieceLastBand = scratchPieceLastBand;
343
290
  let xLeft = Number.POSITIVE_INFINITY;
291
+ let xRight = Number.NEGATIVE_INFINITY;
344
292
  for (let pieceIndex = 0; pieceIndex < pieceCount; pieceIndex++) {
345
293
  if ((pieceIndex & 255) === 0) throwIfAborted(signal);
346
294
  const offset = pieceIndex * 6;
@@ -353,7 +301,9 @@ function fileBands(pieces, pieceCount, y0, y1, packed, targetPiecesPerBand, sign
353
301
  if (py2 > yMax) yMax = py2;
354
302
  const firstBand = bandIndex(yMin, y0, invH, bandCount);
355
303
  const lastBand = bandIndex(yMax, y0, invH, bandCount);
356
- for (let band = firstBand; band <= lastBand; band++) buckets[band].push(pieceIndex);
304
+ pieceFirstBand[pieceIndex] = firstBand;
305
+ pieceLastBand[pieceIndex] = lastBand;
306
+ for (let band = firstBand; band <= lastBand; band++) scratchBucketCounts[band]++;
357
307
  const fPy0 = Math.fround(py0);
358
308
  pieceHasYSpan[pieceIndex] = fPy0 !== Math.fround(py1) || fPy0 !== Math.fround(py2) ? 1 : 0;
359
309
  const px0 = pieces[offset];
@@ -366,77 +316,141 @@ function fileBands(pieces, pieceCount, y0, y1, packed, targetPiecesPerBand, sign
366
316
  pieceXMin[pieceIndex] = xMin;
367
317
  pieceXMax[pieceIndex] = xMax;
368
318
  if (xMin < xLeft) xLeft = xMin;
319
+ if (xMax > xRight) xRight = xMax;
320
+ }
321
+ let totalBanded = 0;
322
+ for (let band = 0; band < bandCount; band++) {
323
+ scratchBucketOffsets[band] = totalBanded;
324
+ totalBanded += scratchBucketCounts[band];
325
+ scratchBucketCounts[band] = scratchBucketOffsets[band];
326
+ }
327
+ scratchBucketOffsets[bandCount] = totalBanded;
328
+ if (totalBanded > scratchBucketData.length) scratchBucketData = new Int32Array(Math.max(scratchBucketData.length * 2, totalBanded));
329
+ const bucketData = scratchBucketData;
330
+ for (let pieceIndex = 0; pieceIndex < pieceCount; pieceIndex++) {
331
+ const firstBand = pieceFirstBand[pieceIndex];
332
+ const lastBand = pieceLastBand[pieceIndex];
333
+ for (let band = firstBand; band <= lastBand; band++) bucketData[scratchBucketCounts[band]++] = pieceIndex;
369
334
  }
370
- const rowBase = packed.rowLen / 6;
335
+ const rowBase = packed.rowLen / 6 + packed.rowIndexOffset;
371
336
  assertUint32(rowBase, "rowBase");
372
337
  const exactBandH = bandCount > 1 ? (y1 - y0) / bandCount : y1 - y0;
373
- const roundedInvH = Math.fround(invH);
374
- if (!Number.isFinite(roundedInvH)) throw new RangeError("inverse band height must be representable as a finite float32");
375
- const bandH = bandCount > 1 && roundedInvH > 0 ? Math.fround(1 / roundedInvH) : Math.fround(exactBandH);
376
- if (!Number.isFinite(bandH)) throw new RangeError("band height must be representable as a finite float32");
338
+ const roundedInvH = checkFloat32(invH, "inverse band height");
339
+ const bandH = checkFloat32(bandCount > 1 && roundedInvH > 0 ? 1 / roundedInvH : exactBandH, "band height");
377
340
  const gather = scratchGather;
378
341
  const byXMin = scratchByXMin;
342
+ const bandSource = scratchBandSource;
343
+ const bandXMin = scratchBandXMin;
344
+ const bandXMax = scratchBandXMax;
379
345
  const rows = ensureRowCapacity(packed.rowLen + bandCount * 6, packed.rowLen);
346
+ const fY0 = Math.fround(y0);
347
+ const clipEps = Math.max(exactBandH, bandH) * .002 + clipScale * 6103515625e-14;
348
+ const clipBands = clipScale > 0 && bandCount > 1 && exactBandH > 0;
349
+ const minClipSpan = xRight > xLeft ? (xRight - xLeft) * .04 : 0;
380
350
  for (let band = 0; band < bandCount; band++) {
381
351
  throwIfAborted(signal);
382
- const bucket = buckets[band];
383
- const bucketLen = bucket.length;
384
- for (let i = 1; i < bucketLen; i++) {
385
- const idx = bucket[i];
386
- const key = pieceXMax[idx];
387
- let j = i - 1;
388
- while (j >= 0 && pieceXMax[bucket[j]] < key) {
389
- bucket[j + 1] = bucket[j];
390
- j--;
391
- }
392
- bucket[j + 1] = idx;
393
- }
352
+ const bucketOffset = scratchBucketOffsets[band];
353
+ const bucketLen = scratchBucketOffsets[band + 1] - bucketOffset;
394
354
  let gatherLen = 0;
355
+ let clippedFloats = 0;
395
356
  let xMin = FLOAT32_FAR;
396
357
  let xMax = -3e38;
358
+ const clipLo = !clipBands || band === 0 ? -Infinity : Math.min(y0 + band * exactBandH, fY0 + band * bandH) - clipEps;
359
+ const clipHi = !clipBands || band + 1 === bandCount ? Infinity : Math.max(y0 + (band + 1) * exactBandH, fY0 + (band + 1) * bandH) + clipEps;
397
360
  for (let i = 0; i < bucketLen; i++) {
398
- const pieceIndex = bucket[i];
399
- const pMin = pieceXMin[pieceIndex];
400
- const pMax = pieceXMax[pieceIndex];
401
- if (pMin < xMin) xMin = pMin;
402
- if (pMax > xMax) xMax = pMax;
403
- if (pieceHasYSpan[pieceIndex]) {
404
- gather[gatherLen] = pieceIndex;
405
- byXMin[gatherLen] = pieceIndex;
406
- gatherLen++;
361
+ const pieceIndex = bucketData[bucketOffset + i];
362
+ let pMin = pieceXMin[pieceIndex];
363
+ let pMax = pieceXMax[pieceIndex];
364
+ if (!pieceHasYSpan[pieceIndex]) {
365
+ if (pMin < xMin) xMin = pMin;
366
+ if (pMax > xMax) xMax = pMax;
367
+ continue;
407
368
  }
408
- }
409
- for (let i = 1; i < gatherLen; i++) {
410
- const idx = byXMin[i];
411
- const key = pieceXMin[idx];
412
- let j = i - 1;
413
- while (j >= 0 && pieceXMin[byXMin[j]] > key) {
414
- byXMin[j + 1] = byXMin[j];
415
- j--;
369
+ const offset = pieceIndex * 6;
370
+ let sourceOff = offset;
371
+ if (clipBands && pMax - pMin > minClipSpan) {
372
+ const needLo = pieceFirstBand[pieceIndex] < band;
373
+ const needHi = pieceLastBand[pieceIndex] > band;
374
+ if (needLo || needHi) {
375
+ const py0 = pieces[offset + 1];
376
+ const py1 = pieces[offset + 3];
377
+ const py2 = pieces[offset + 5];
378
+ const rising = py2 >= py0;
379
+ const ay = py0 - 2 * py1 + py2;
380
+ const hy = py1 - py0;
381
+ const ta = rising ? needLo ? monotoneRoot(ay, hy, py0, py2, clipLo, true) : 0 : needHi ? monotoneRoot(ay, hy, py0, py2, clipHi, false) : 0;
382
+ const tb = rising ? needHi ? monotoneRoot(ay, hy, py0, py2, clipHi, true) : 1 : needLo ? monotoneRoot(ay, hy, py0, py2, clipLo, false) : 1;
383
+ if ((ta > 0 || tb < 1) && tb > ta) {
384
+ const px0 = pieces[offset], px1 = pieces[offset + 2], px2 = pieces[offset + 4], ua = 1 - ta, ub = 1 - tb, qx0 = ua * ua * px0 + 2 * ua * ta * px1 + ta * ta * px2, qy0 = ua * ua * py0 + 2 * ua * ta * py1 + ta * ta * py2, qx2 = ub * ub * px0 + 2 * ub * tb * px1 + tb * tb * px2, qy2 = ub * ub * py0 + 2 * ub * tb * py1 + tb * tb * py2, cMinX = qx0 < qx2 ? qx0 : qx2, cMaxX = qx0 > qx2 ? qx0 : qx2, cMinY = qy0 < qy2 ? qy0 : qy2, cMaxY = qy0 > qy2 ? qy0 : qy2;
385
+ let qx1 = ua * ub * px0 + (ua * tb + ta * ub) * px1 + ta * tb * px2, qy1 = ua * ub * py0 + (ua * tb + ta * ub) * py1 + ta * tb * py2;
386
+ if (qx1 < cMinX) qx1 = cMinX;
387
+ else if (qx1 > cMaxX) qx1 = cMaxX;
388
+ if (qy1 < cMinY) qy1 = cMinY;
389
+ else if (qy1 > cMaxY) qy1 = cMaxY;
390
+ pMin = cMinX;
391
+ pMax = cMaxX;
392
+ if (clippedFloats + 6 > scratchBandClipped.length) {
393
+ const grown = new Float64Array(Math.max(scratchBandClipped.length * 2, clippedFloats + 6));
394
+ grown.set(scratchBandClipped.subarray(0, clippedFloats));
395
+ scratchBandClipped = grown;
396
+ }
397
+ scratchBandClipped[clippedFloats] = qx0;
398
+ scratchBandClipped[clippedFloats + 1] = qy0;
399
+ scratchBandClipped[clippedFloats + 2] = qx1;
400
+ scratchBandClipped[clippedFloats + 3] = qy1;
401
+ scratchBandClipped[clippedFloats + 4] = qx2;
402
+ scratchBandClipped[clippedFloats + 5] = qy2;
403
+ sourceOff = ~clippedFloats;
404
+ clippedFloats += 6;
405
+ }
406
+ }
416
407
  }
417
- byXMin[j + 1] = idx;
408
+ if (pMin < xMin) xMin = pMin;
409
+ if (pMax > xMax) xMax = pMax;
410
+ bandSource[gatherLen] = sourceOff;
411
+ bandXMin[gatherLen] = pMin;
412
+ bandXMax[gatherLen] = pMax;
413
+ gather[gatherLen] = gatherLen;
414
+ byXMin[gatherLen] = gatherLen;
415
+ gatherLen++;
418
416
  }
419
- const curveStart = packed.curveLen / 6;
417
+ const curveStart = packed.curveLen / 6 + packed.curveStartOffset;
420
418
  assertUint32(curveStart, "curveStart");
421
419
  assertUint32(gatherLen, "curveCount");
422
420
  const curves = ensureCurveCapacity(packed.curveLen + gatherLen * 12, packed.curveLen);
421
+ const bandClipped = scratchBandClipped;
423
422
  let curveWrite = packed.curveLen;
424
423
  for (let traversal = 0; traversal < 2; traversal++) {
425
424
  const list = traversal ? byXMin : gather;
425
+ const keys = traversal ? bandXMin : bandXMax;
426
+ for (let i = 1; i < gatherLen; i++) {
427
+ const idx = list[i], key = keys[idx];
428
+ let j = i - 1;
429
+ while (j >= 0 && (traversal ? keys[list[j]] > key : keys[list[j]] < key)) {
430
+ list[j + 1] = list[j];
431
+ j--;
432
+ }
433
+ list[j + 1] = idx;
434
+ }
435
+ const q2Start = curveWrite + gatherLen * 4;
426
436
  for (let i = 0; i < gatherLen; i++) {
427
- const offset = list[i] * 6;
428
- curves[curveWrite] = pieces[offset];
429
- curves[curveWrite + 1] = pieces[offset + 1];
430
- curves[curveWrite + 2] = pieces[offset + 2];
431
- curves[curveWrite + 3] = pieces[offset + 3];
432
- curves[curveWrite + 4] = pieces[offset + 4];
433
- curves[curveWrite + 5] = pieces[offset + 5];
434
- curveWrite += 6;
437
+ const srcOff = bandSource[list[i]];
438
+ const src = srcOff < 0 ? bandClipped : pieces;
439
+ const off = srcOff < 0 ? ~srcOff : srcOff;
440
+ const pairOff = curveWrite + i * 4;
441
+ const midOff = q2Start + i * 2;
442
+ curves[pairOff] = src[off];
443
+ curves[pairOff + 1] = src[off + 1];
444
+ curves[pairOff + 2] = src[off + 4];
445
+ curves[pairOff + 3] = src[off + 5];
446
+ curves[midOff] = src[off + 2];
447
+ curves[midOff + 1] = src[off + 3];
435
448
  }
449
+ curveWrite += gatherLen * 6;
436
450
  }
437
451
  packed.curveLen = curveWrite;
438
- const split = balancedSplit(byXMin, gather, gatherLen, pieceXMin, pieceXMax);
439
- const density = (pieceCount ? bandWindingArea(pieces, bucket, xLeft, y0 + band * exactBandH, y0 + (band + 1) * exactBandH) : 0) / Math.max(bandH * (xMax - xMin), 1e-30);
452
+ const split = balancedSplit(byXMin, gather, gatherLen, bandXMin, bandXMax);
453
+ const density = (pieceCount ? bandWindingArea(pieces, bucketData, bucketOffset, bucketLen, xLeft, y0 + band * exactBandH, y0 + (band + 1) * exactBandH) : 0) / Math.max(bandH * (xMax - xMin), 1e-30);
440
454
  const rowWrite = packed.rowLen;
441
455
  rows[rowWrite] = curveStart;
442
456
  rows[rowWrite + 1] = gatherLen;
@@ -453,9 +467,6 @@ function fileBands(pieces, pieceCount, y0, y1, packed, targetPiecesPerBand, sign
453
467
  invH: roundedInvH
454
468
  };
455
469
  }
456
- function compareKeys(left, right) {
457
- return left[0] < right[0] ? -1 : left[0] > right[0] ? 1 : 0;
458
- }
459
470
  function shouldTransposeLayer(pieces, pieceFloats, bbox, monotonePieceCount, bands) {
460
471
  const xLow = bbox[0], xHigh = bbox[2], xExtent = xHigh - xLow;
461
472
  const yLow = bbox[1], yHigh = bbox[3], yExtent = yHigh - yLow;
@@ -475,6 +486,9 @@ function shouldTransposeLayer(pieces, pieceFloats, bbox, monotonePieceCount, ban
475
486
  * Conflicting outlines under one key reject instead of making sharing order-dependent.
476
487
  */
477
488
  function preprocessWindfoilGlyphs(sources, options = {}) {
489
+ return preprocessWindfoilGlyphsBatch(sources, options, 0, 0);
490
+ }
491
+ function preprocessWindfoilGlyphsBatch(sources, options = {}, curveFloatOffset = 0, rowUintOffset = 0) {
478
492
  throwIfAborted(options.signal);
479
493
  const targetPiecesPerBand = options.targetPiecesPerBand ?? 10;
480
494
  if (!Number.isInteger(targetPiecesPerBand) || targetPiecesPerBand <= 0) throw new RangeError("targetPiecesPerBand must be a positive integer");
@@ -494,99 +508,90 @@ function preprocessWindfoilGlyphs(sources, options = {}) {
494
508
  }
495
509
  const packed = {
496
510
  curveLen: 0,
497
- rowLen: 0
511
+ rowLen: 0,
512
+ curveStartOffset: curveFloatOffset / 6,
513
+ rowIndexOffset: rowUintOffset / 6
498
514
  };
499
515
  const glyphs = /* @__PURE__ */ new Map();
500
516
  let monotonePieces = 0;
501
517
  let paintLayers = 0;
502
518
  let layered = false;
503
519
  try {
504
- const sortedGlyphs = [...unique.entries()].sort(compareKeys);
520
+ const sortedGlyphs = [...unique.entries()].sort((a, b) => a[0] < b[0] ? -1 : a[0] > b[0] ? 1 : 0);
505
521
  for (const [key, outline] of sortedGlyphs) {
506
522
  throwIfAborted(options.signal);
507
- const layers = [];
508
- const orient = outline.layers && options.orientLayers?.(outline);
509
- const inputs = outline.layers ?? [{
510
- quadratics: outline.quadratics,
511
- bbox: outline.bbox,
512
- paint: { type: "foreground" },
513
- paintKind: 0,
514
- rgba: [
515
- 0,
516
- 0,
517
- 0,
518
- 1
519
- ],
520
- paintLabel: "paint"
521
- }];
522
- for (const layer of inputs) {
523
+ let rowBase = 0;
524
+ let bandCount = 0;
525
+ let bandH = 0;
526
+ let invH = 0;
527
+ let hasFirst = false;
528
+ let glyphPieces = 0;
529
+ const richLayers = outline.layers;
530
+ const layers = richLayers ? [] : void 0;
531
+ const orient = richLayers && options.orientLayers?.(outline);
532
+ const glyphBox = outline.clipBox ?? outline.bbox;
533
+ const glyphScale = richLayers ? 0 : Math.max(Math.abs(outline.bbox[0]), Math.abs(outline.bbox[1]), Math.abs(outline.bbox[2]), Math.abs(outline.bbox[3]), Math.abs(glyphBox[0]) + (glyphBox[2] - glyphBox[0]), Math.abs(glyphBox[1]) + (glyphBox[3] - glyphBox[1]), 1e-6);
534
+ const layerCount = richLayers ? richLayers.length : 1;
535
+ for (let l = 0; l < layerCount; l++) {
523
536
  throwIfAborted(options.signal);
524
- if (outline.layers && (!layer.quadratics.length || layer.paintKind === 1 && layer.rgba[3] === 0)) continue;
525
- const pieceFloats = splitOutline(layer.quadratics, options.signal);
537
+ const rich = richLayers?.[l];
538
+ if (rich && (!rich.quadratics.length || rich.paintKind === 1 && rich.rgba[3] === 0)) continue;
539
+ const pieceFloats = splitOutline(rich ? rich.quadratics : outline.quadratics, options.signal);
526
540
  const monotonePieceCount = pieceFloats / 6;
527
- if (outline.layers && monotonePieceCount === 0) continue;
541
+ if (rich && monotonePieceCount === 0) continue;
528
542
  monotonePieces += monotonePieceCount;
543
+ glyphPieces += monotonePieceCount;
544
+ if (monotonePieceCount > 0) paintLayers++;
529
545
  const pieces = scratchPieces;
546
+ const bbox = rich ? rich.bbox : outline.bbox;
530
547
  const bands = chooseBandCount(monotonePieceCount, targetPiecesPerBand);
531
- const transposed = !!orient && bands > 1 && shouldTransposeLayer(pieces, pieceFloats, layer.bbox, monotonePieceCount, bands);
548
+ const transposed = !!orient && bands > 1 && shouldTransposeLayer(pieces, pieceFloats, bbox, monotonePieceCount, bands);
532
549
  if (transposed) for (let i = 0; i < pieceFloats; i += 2) {
533
550
  const temp = pieces[i];
534
551
  pieces[i] = pieces[i + 1];
535
552
  pieces[i + 1] = temp;
536
553
  }
537
- const bandHeader = fileBands(pieces, monotonePieceCount, layer.bbox[transposed ? 0 : 1], layer.bbox[transposed ? 2 : 3], packed, targetPiecesPerBand, options.signal);
538
- const layerHeader = transposed ? {
539
- rowBase: bandHeader.rowBase,
540
- bandCount: bandHeader.bandCount,
541
- bandH: bandHeader.bandH,
542
- invH: bandHeader.invH,
543
- transposed: true,
544
- bbox: layer.bbox,
545
- monotonePieceCount,
546
- paintKind: layer.paintKind,
547
- rgba: layer.rgba,
548
- paint: layer.paint,
549
- paintLabel: layer.paintLabel
550
- } : {
551
- rowBase: bandHeader.rowBase,
552
- bandCount: bandHeader.bandCount,
553
- bandH: bandHeader.bandH,
554
- invH: bandHeader.invH,
555
- bbox: layer.bbox,
556
- monotonePieceCount,
557
- paintKind: layer.paintKind,
558
- rgba: layer.rgba,
559
- paint: layer.paint,
560
- paintLabel: layer.paintLabel
561
- };
562
- layers.push(layerHeader);
563
- }
564
- const first = layers[0] ?? {
565
- rowBase: 0,
566
- bandCount: 0,
567
- bandH: 0,
568
- invH: 0
569
- };
570
- let glyphPieces = 0;
571
- for (const layer of layers) {
572
- if (layer.monotonePieceCount > 0) paintLayers++;
573
- glyphPieces += layer.monotonePieceCount;
574
- if (!layered && (layer.paintKind !== 0 || layer.rgba[3] !== 1)) layered = true;
554
+ const h = fileBands(pieces, monotonePieceCount, bbox[transposed ? 0 : 1], bbox[transposed ? 2 : 3], glyphScale, packed, targetPiecesPerBand, options.signal);
555
+ if (!hasFirst) {
556
+ hasFirst = true;
557
+ rowBase = h.rowBase;
558
+ bandCount = h.bandCount;
559
+ bandH = h.bandH;
560
+ invH = h.invH;
561
+ }
562
+ if (rich && layers) {
563
+ if (!layered && (rich.paintKind !== 0 || rich.rgba[3] !== 1)) layered = true;
564
+ const lh = {
565
+ rowBase: h.rowBase,
566
+ bandCount: h.bandCount,
567
+ bandH: h.bandH,
568
+ invH: h.invH,
569
+ bbox: rich.bbox,
570
+ monotonePieceCount,
571
+ paintKind: rich.paintKind,
572
+ rgba: rich.rgba,
573
+ paint: rich.paint,
574
+ paintLabel: rich.paintLabel
575
+ };
576
+ if (transposed) lh.transposed = true;
577
+ layers.push(lh);
578
+ }
575
579
  }
576
- if (layers.length > 1) layered = true;
577
- glyphs.set(key, {
578
- rowBase: first.rowBase,
579
- bandCount: first.bandCount,
580
- bandH: first.bandH,
581
- invH: first.invH,
580
+ if (layers && layers.length > 1) layered = true;
581
+ const header = {
582
+ rowBase,
583
+ bandCount,
584
+ bandH,
585
+ invH,
582
586
  unitsPerEm: outline.unitsPerEm,
583
587
  ascent: outline.ascent,
584
588
  descent: outline.descent,
585
589
  bbox: outline.bbox,
586
- monotonePieceCount: glyphPieces,
587
- ...outline.layers ? { layers } : {},
588
- ...outline.clipBox ? { clipBox: outline.clipBox } : {}
589
- });
590
+ monotonePieceCount: glyphPieces
591
+ };
592
+ if (layers) header.layers = layers;
593
+ if (outline.clipBox) header.clipBox = outline.clipBox;
594
+ glyphs.set(key, header);
590
595
  }
591
596
  throwIfAborted(options.signal);
592
597
  let bandedPieces = 0;
@@ -606,18 +611,22 @@ function preprocessWindfoilGlyphs(sources, options = {}) {
606
611
  }
607
612
  };
608
613
  } finally {
609
- if (scratchPieces.length > 98304) {
610
- for (let i = 0; i < 64; i++) scratchBuckets[i].length = 0;
611
- scratchPieces = /* @__PURE__ */ new Float64Array(1024);
612
- }
614
+ if (scratchPieces.length > 98304) scratchPieces = /* @__PURE__ */ new Float64Array(1024);
615
+ if (scratchBucketData.length > 65536) scratchBucketData = /* @__PURE__ */ new Int32Array(512);
616
+ if (scratchBandClipped.length > 65536) scratchBandClipped = /* @__PURE__ */ new Float64Array(256);
613
617
  if (scratchCurves.length > 262144) scratchCurves = /* @__PURE__ */ new Float32Array(0);
614
618
  if (scratchRows.length > 65536) scratchRows = /* @__PURE__ */ new Uint32Array(0);
615
619
  if (scratchPieceXMin.length > 16384) {
616
620
  scratchPieceXMin = /* @__PURE__ */ new Float64Array(256);
617
621
  scratchPieceXMax = /* @__PURE__ */ new Float64Array(256);
618
622
  scratchPieceHasYSpan = /* @__PURE__ */ new Uint8Array(256);
623
+ scratchPieceFirstBand = /* @__PURE__ */ new Uint8Array(256);
624
+ scratchPieceLastBand = /* @__PURE__ */ new Uint8Array(256);
619
625
  scratchGather = /* @__PURE__ */ new Int32Array(256);
620
626
  scratchByXMin = /* @__PURE__ */ new Int32Array(256);
627
+ scratchBandSource = /* @__PURE__ */ new Int32Array(256);
628
+ scratchBandXMin = /* @__PURE__ */ new Float64Array(256);
629
+ scratchBandXMax = /* @__PURE__ */ new Float64Array(256);
621
630
  }
622
631
  }
623
632
  }
@@ -628,6 +637,6 @@ function preprocessWindfoilOutlines(sources, options = {}) {
628
637
  outline: source.outline
629
638
  })), options);
630
639
  }
631
- export { WINDFOIL_MAX_LAYERS, preprocessWindfoilGlyphs, preprocessWindfoilOutlines, readBox, readFiniteFloat32, readFlatCoordinates, readFlatNumbers, validateWindfoilGlyphOutline };
640
+ export { preprocessWindfoilGlyphs, preprocessWindfoilGlyphsBatch, preprocessWindfoilOutlines, readBox, readFiniteFloat32, readFlatCoordinates, validateWindfoilGlyphOutline };
632
641
 
633
642
  //# sourceMappingURL=preprocessCore.js.map