ultra-text 1.0.1 → 1.0.3

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 (237) hide show
  1. package/README.md +339 -1039
  2. package/dist/assets/cpuSdf.worker-Dy4P5_TI.js +466 -0
  3. package/dist/assets/cpuSdf.worker-Dy4P5_TI.js.map +1 -0
  4. package/dist/assets/traceOutline.worker-B5uVKmR4.js +1725 -0
  5. package/dist/assets/traceOutline.worker-B5uVKmR4.js.map +1 -0
  6. package/dist/atlas/appendAtlas.js +97 -31
  7. package/dist/atlas/appendAtlas.js.map +1 -1
  8. package/dist/atlas/buildAtlas.js +4 -3
  9. package/dist/atlas/buildAtlas.js.map +1 -1
  10. package/dist/atlas/colorGlyphs.d.ts +0 -10
  11. package/dist/atlas/colorGlyphs.js +97 -155
  12. package/dist/atlas/colorGlyphs.js.map +1 -1
  13. package/dist/atlas/colorTexture.d.ts +1 -0
  14. package/dist/atlas/colorTexture.js +64 -0
  15. package/dist/atlas/colorTexture.js.map +1 -0
  16. package/dist/atlas/cpuAtlas.d.ts +4 -1
  17. package/dist/atlas/cpuAtlas.js +14 -7
  18. package/dist/atlas/cpuAtlas.js.map +1 -1
  19. package/dist/atlas/cpuSdf.d.ts +1 -1
  20. package/dist/atlas/cpuSdf.js +235 -68
  21. package/dist/atlas/cpuSdf.js.map +1 -1
  22. package/dist/atlas/cpuWorker.d.ts +11 -3
  23. package/dist/atlas/cpuWorker.js +179 -22
  24. package/dist/atlas/cpuWorker.js.map +1 -1
  25. package/dist/atlas/gpuAtlas.js +188 -287
  26. package/dist/atlas/gpuAtlas.js.map +1 -1
  27. package/dist/atlas/gpuCommon.d.ts +257 -0
  28. package/dist/atlas/gpuCommon.js +845 -0
  29. package/dist/atlas/gpuCommon.js.map +1 -0
  30. package/dist/atlas/jfaWgsl.d.ts +1 -1
  31. package/dist/atlas/jfaWgsl.js +226 -249
  32. package/dist/atlas/jfaWgsl.js.map +1 -1
  33. package/dist/atlas/rasterize.d.ts +22 -0
  34. package/dist/atlas/rasterize.js +329 -158
  35. package/dist/atlas/rasterize.js.map +1 -1
  36. package/dist/atlas/shapeRaster.js +2 -1
  37. package/dist/atlas/shapeRaster.js.map +1 -1
  38. package/dist/atlas/vanillaBounds.d.ts +64 -0
  39. package/dist/atlas/vanillaBounds.js +42 -0
  40. package/dist/atlas/vanillaBounds.js.map +1 -0
  41. package/dist/atlas/vanillaCore.d.ts +100 -0
  42. package/dist/atlas/vanillaCore.js +1065 -0
  43. package/dist/atlas/vanillaCore.js.map +1 -0
  44. package/dist/atlas/vanillaCpuAtlas.d.ts +9 -0
  45. package/dist/atlas/vanillaCpuAtlas.js +72 -0
  46. package/dist/atlas/vanillaCpuAtlas.js.map +1 -0
  47. package/dist/atlas/vanillaExtras.d.ts +8 -0
  48. package/dist/atlas/vanillaExtras.js +167 -0
  49. package/dist/atlas/vanillaExtras.js.map +1 -0
  50. package/dist/atlas/vanillaGpuHelpers.d.ts +295 -0
  51. package/dist/atlas/vanillaGpuHelpers.js +354 -0
  52. package/dist/atlas/vanillaGpuHelpers.js.map +1 -0
  53. package/dist/dom/DomSdf.js +243 -297
  54. package/dist/dom/DomSdf.js.map +1 -1
  55. package/dist/dom/DomSlug.js +94 -165
  56. package/dist/dom/DomSlug.js.map +1 -1
  57. package/dist/dom/Text.d.ts +4 -1
  58. package/dist/dom/Text.js +5 -1
  59. package/dist/dom/Text.js.map +1 -1
  60. package/dist/dom/browserShaping.js +31 -14
  61. package/dist/dom/browserShaping.js.map +1 -1
  62. package/dist/dom/clusters.js +13 -2
  63. package/dist/dom/clusters.js.map +1 -1
  64. package/dist/dom/cssEffects.d.ts +4 -0
  65. package/dist/dom/cssEffects.js +72 -0
  66. package/dist/dom/cssEffects.js.map +1 -0
  67. package/dist/dom/domAnalytic.d.ts +53 -0
  68. package/dist/dom/domAnalytic.js +282 -0
  69. package/dist/dom/domAnalytic.js.map +1 -0
  70. package/dist/dom/domExtras.d.ts +27 -0
  71. package/dist/dom/domExtras.js +137 -0
  72. package/dist/dom/domExtras.js.map +1 -0
  73. package/dist/dom/fontCanvas.d.ts +16 -0
  74. package/dist/dom/fontCanvas.js +31 -13
  75. package/dist/dom/fontCanvas.js.map +1 -1
  76. package/dist/dom/layoutSignature.js +175 -57
  77. package/dist/dom/layoutSignature.js.map +1 -1
  78. package/dist/dom/markup.d.ts +10 -0
  79. package/dist/dom/markup.js +16 -1
  80. package/dist/dom/markup.js.map +1 -1
  81. package/dist/dom/pretextLayout.js +78 -28
  82. package/dist/dom/pretextLayout.js.map +1 -1
  83. package/dist/dom/snapshot.d.ts +4 -0
  84. package/dist/dom/snapshot.js +891 -484
  85. package/dist/dom/snapshot.js.map +1 -1
  86. package/dist/dom/snapshotsEqual.d.ts +7 -0
  87. package/dist/dom/snapshotsEqual.js +68 -0
  88. package/dist/dom/snapshotsEqual.js.map +1 -0
  89. package/dist/dom/svgCapture.d.ts +8 -1
  90. package/dist/dom/svgCapture.js +105 -28
  91. package/dist/dom/svgCapture.js.map +1 -1
  92. package/dist/dom/textTransform.d.ts +13 -1
  93. package/dist/dom/textTransform.js +31 -13
  94. package/dist/dom/textTransform.js.map +1 -1
  95. package/dist/dom/tone.js +91 -44
  96. package/dist/dom/tone.js.map +1 -1
  97. package/dist/index.js +4 -3
  98. package/dist/slug/SlugMaterial.d.ts +17 -3
  99. package/dist/slug/SlugMaterial.js +98 -26
  100. package/dist/slug/SlugMaterial.js.map +1 -1
  101. package/dist/slug/cff.d.ts +5 -0
  102. package/dist/slug/cff.js +780 -0
  103. package/dist/slug/cff.js.map +1 -0
  104. package/dist/slug/coverage.d.ts +19 -15
  105. package/dist/slug/coverage.js +380 -225
  106. package/dist/slug/coverage.js.map +1 -1
  107. package/dist/slug/preprocessCore.d.ts +6 -2
  108. package/dist/slug/preprocessCore.js +199 -148
  109. package/dist/slug/preprocessCore.js.map +1 -1
  110. package/dist/slug/runtime.d.ts +1 -0
  111. package/dist/slug/runtime.js +113 -74
  112. package/dist/slug/runtime.js.map +1 -1
  113. package/dist/slug/standaloneRuntime.d.ts +3 -2
  114. package/dist/slug/standaloneRuntime.js +112 -67
  115. package/dist/slug/standaloneRuntime.js.map +1 -1
  116. package/dist/slug/truetype.d.ts +14 -6
  117. package/dist/slug/truetype.js +356 -255
  118. package/dist/slug/truetype.js.map +1 -1
  119. package/dist/slug/vanillaCore.d.ts +410 -0
  120. package/dist/slug/vanillaCore.js +1630 -0
  121. package/dist/slug/vanillaCore.js.map +1 -0
  122. package/dist/slug-vanilla.d.ts +13 -364
  123. package/dist/slug-vanilla.js +7 -1454
  124. package/dist/slug.d.ts +2 -2
  125. package/dist/slug.js +7 -7
  126. package/dist/text/GlyphTextMaterial.d.ts +6 -1
  127. package/dist/text/GlyphTextMaterial.js +16 -12
  128. package/dist/text/GlyphTextMaterial.js.map +1 -1
  129. package/dist/text/RectMaterial.js +6 -10
  130. package/dist/text/RectMaterial.js.map +1 -1
  131. package/dist/text/SdfTextMaterial.d.ts +9 -3
  132. package/dist/text/SdfTextMaterial.js +125 -38
  133. package/dist/text/SdfTextMaterial.js.map +1 -1
  134. package/dist/text/decorations.d.ts +7 -2
  135. package/dist/text/decorations.js +187 -79
  136. package/dist/text/decorations.js.map +1 -1
  137. package/dist/text/geometry.d.ts +3 -22
  138. package/dist/text/geometryUtils.d.ts +16 -1
  139. package/dist/text/geometryUtils.js +83 -8
  140. package/dist/text/geometryUtils.js.map +1 -1
  141. package/dist/text/glyphGeometry.d.ts +9 -0
  142. package/dist/text/glyphGeometry.js +434 -0
  143. package/dist/text/glyphGeometry.js.map +1 -0
  144. package/dist/text/index.d.ts +2 -1
  145. package/dist/text/rectGeometry.d.ts +13 -0
  146. package/dist/text/rectGeometry.js +101 -0
  147. package/dist/text/rectGeometry.js.map +1 -0
  148. package/dist/text/reflow.d.ts +23 -1
  149. package/dist/text/reflow.js +223 -94
  150. package/dist/text/reflow.js.map +1 -1
  151. package/dist/text/snap.d.ts +15 -0
  152. package/dist/text/snap.js +26 -0
  153. package/dist/text/snap.js.map +1 -0
  154. package/dist/text/tone.js +2 -2
  155. package/dist/text/tone.js.map +1 -1
  156. package/dist/types.d.ts +23 -7
  157. package/dist/vanilla.d.ts +13 -363
  158. package/dist/vanilla.js +7 -1474
  159. package/dist/windfoil/WindfoilCompositeMaterial.d.ts +1 -1
  160. package/dist/windfoil/WindfoilCompositeMaterial.js +10 -3
  161. package/dist/windfoil/WindfoilCompositeMaterial.js.map +1 -1
  162. package/dist/windfoil/WindfoilMaterial.d.ts +12 -5
  163. package/dist/windfoil/WindfoilMaterial.js +71 -8
  164. package/dist/windfoil/WindfoilMaterial.js.map +1 -1
  165. package/dist/windfoil/compositeGeometry.js +12 -5
  166. package/dist/windfoil/compositeGeometry.js.map +1 -1
  167. package/dist/windfoil/coverage.d.ts +10 -2
  168. package/dist/windfoil/coverage.js +147 -59
  169. package/dist/windfoil/coverage.js.map +1 -1
  170. package/dist/windfoil/geometry.d.ts +17 -2
  171. package/dist/windfoil/geometry.js +220 -57
  172. package/dist/windfoil/geometry.js.map +1 -1
  173. package/dist/windfoil/layerGrid.js +8 -8
  174. package/dist/windfoil/layerGrid.js.map +1 -1
  175. package/dist/windfoil/mixed.d.ts +1 -0
  176. package/dist/windfoil/mixed.js +57 -29
  177. package/dist/windfoil/mixed.js.map +1 -1
  178. package/dist/windfoil/preprocess.js +2 -2
  179. package/dist/windfoil/preprocessCore.d.ts +2 -0
  180. package/dist/windfoil/preprocessCore.js +69 -37
  181. package/dist/windfoil/preprocessCore.js.map +1 -1
  182. package/dist/windfoil/requests.d.ts +1 -1
  183. package/dist/windfoil/requests.js +11 -4
  184. package/dist/windfoil/requests.js.map +1 -1
  185. package/dist/windfoil/resolveOutline.d.ts +9 -0
  186. package/dist/windfoil/resolveOutline.js +20 -0
  187. package/dist/windfoil/resolveOutline.js.map +1 -0
  188. package/dist/windfoil/runtime.d.ts +4 -1
  189. package/dist/windfoil/runtime.js +69 -63
  190. package/dist/windfoil/runtime.js.map +1 -1
  191. package/dist/windfoil/shapeGeometry.js +80 -34
  192. package/dist/windfoil/shapeGeometry.js.map +1 -1
  193. package/dist/windfoil/sizeSwitch.d.ts +1 -1
  194. package/dist/windfoil/sizeSwitch.js +13 -8
  195. package/dist/windfoil/sizeSwitch.js.map +1 -1
  196. package/dist/windfoil/storage.d.ts +78 -6
  197. package/dist/windfoil/storage.js +166 -11
  198. package/dist/windfoil/storage.js.map +1 -1
  199. package/dist/windfoil/svg/curves.d.ts +20 -0
  200. package/dist/windfoil/svg/curves.js +145 -42
  201. package/dist/windfoil/svg/curves.js.map +1 -1
  202. package/dist/windfoil/svg/document.js +10 -1
  203. package/dist/windfoil/svg/document.js.map +1 -1
  204. package/dist/windfoil/svg/pathConverter.js +66 -50
  205. package/dist/windfoil/svg/pathConverter.js.map +1 -1
  206. package/dist/windfoil/svg/pathData.d.ts +9 -0
  207. package/dist/windfoil/svg/pathData.js +142 -109
  208. package/dist/windfoil/svg/pathData.js.map +1 -1
  209. package/dist/windfoil/svg/winding.js +34 -10
  210. package/dist/windfoil/svg/winding.js.map +1 -1
  211. package/dist/windfoil/trace/contours.d.ts +5 -0
  212. package/dist/windfoil/trace/contours.js +256 -62
  213. package/dist/windfoil/trace/contours.js.map +1 -1
  214. package/dist/windfoil/trace/fit.d.ts +3 -1
  215. package/dist/windfoil/trace/fit.js +915 -265
  216. package/dist/windfoil/trace/fit.js.map +1 -1
  217. package/dist/windfoil/trace/outline.js +55 -30
  218. package/dist/windfoil/trace/outline.js.map +1 -1
  219. package/dist/windfoil/trace/traceOutline.worker.d.ts +24 -0
  220. package/dist/windfoil/trace/traceWorker.d.ts +13 -0
  221. package/dist/windfoil/trace/traceWorker.js +192 -0
  222. package/dist/windfoil/trace/traceWorker.js.map +1 -0
  223. package/dist/windfoil/trace/types.d.ts +10 -0
  224. package/dist/windfoil/tracedOutlines.d.ts +2 -0
  225. package/dist/windfoil/tracedOutlines.js +393 -103
  226. package/dist/windfoil/tracedOutlines.js.map +1 -1
  227. package/package.json +48 -29
  228. package/skills/ultra-text/SKILL.md +9 -10
  229. package/skills/ultra-text/references/frameworks.md +46 -2
  230. package/skills/ultra-text/references/three-tsl.md +27 -25
  231. package/skills/ultra-text/references/vanilla-webgpu.md +5 -2
  232. package/dist/assets/cpuSdf.worker-xS57yQbP.js +0 -322
  233. package/dist/assets/cpuSdf.worker-xS57yQbP.js.map +0 -1
  234. package/dist/slug-vanilla.js.map +0 -1
  235. package/dist/text/geometry.js +0 -348
  236. package/dist/text/geometry.js.map +0 -1
  237. package/dist/vanilla.js.map +0 -1
@@ -1,4 +1,6 @@
1
1
  import { readBox, readFiniteFloat32, readFlatNumbers } from "../windfoil/outlineValidation.js";
2
+ // src/slug/preprocessCore.ts
3
+ var SLUG_TARGET_PIECES_PER_BAND = 1.5;
2
4
  function throwIfAborted(signal) {
3
5
  if (signal?.aborted) throw signal.reason ?? new DOMException("Slug preprocessing was aborted", "AbortError");
4
6
  }
@@ -6,10 +8,6 @@ function chooseBandCount(pieceCount, targetPiecesPerBand) {
6
8
  if (pieceCount <= targetPiecesPerBand) return 1;
7
9
  return Math.min(Math.ceil(pieceCount / targetPiecesPerBand), 32);
8
10
  }
9
- function bandIndex(coord, origin, invSpan, bandCount) {
10
- if (invSpan <= 0) return 0;
11
- return Math.min(Math.max(Math.floor((coord - origin) * invSpan), 0), bandCount - 1);
12
- }
13
11
  function extremumParameter(start, control, end) {
14
12
  const secondDifference = start - 2 * control + end;
15
13
  if (Math.abs(secondDifference) <= 1e-7) return void 0;
@@ -109,9 +107,12 @@ var xMaxScratch = /* @__PURE__ */ new Float32Array(256);
109
107
  var yMinScratch = /* @__PURE__ */ new Float32Array(256);
110
108
  var yMaxScratch = /* @__PURE__ */ new Float32Array(256);
111
109
  var spanFlagsScratch = /* @__PURE__ */ new Uint8Array(256);
112
- var bandClippedScratch = /* @__PURE__ */ new Float32Array(1536);
113
- var bandRayMaxScratch = /* @__PURE__ */ new Float32Array(256);
114
- var descOrder = /* @__PURE__ */ new Int32Array(256);
110
+ var collinearScratch = /* @__PURE__ */ new Uint8Array(256);
111
+ var MAX_ROW_CURVES = 63;
112
+ var bandClippedScratch = /* @__PURE__ */ new Float32Array(378);
113
+ var bandRayMaxScratch = new Float32Array(MAX_ROW_CURVES);
114
+ var bandLinearScratch = new Uint8Array(MAX_ROW_CURVES);
115
+ var descOrder = new Uint8Array(MAX_ROW_CURVES);
115
116
  var scratchCurves = /* @__PURE__ */ new Float32Array(1024);
116
117
  var scratchRows = /* @__PURE__ */ new Uint32Array(256);
117
118
  function ensureSlugCurveCapacity(required, currentLen) {
@@ -140,36 +141,43 @@ function solveMonotoneT(v0, vc, v1, target) {
140
141
  const q = v0 < v1 ? b - d : b + d;
141
142
  return Math.abs(q) > 1e-12 ? Math.min(Math.max(c / q, 0), 1) : 0;
142
143
  }
143
- function packBandRow(curveStart, count, bandUMin, bandUMax, uMinGlyph, uMaxGlyph, uInvSpan) {
144
- const safeCount = count > 63 ? 63 : count;
145
- if (safeCount === 0 || uInvSpan <= 0) return curveStart << 12 | safeCount;
144
+ var SLUG_CURVE_START_LIMIT = 1 << 17;
145
+ var SLUG_CURVE_START_LIMIT_VEC2 = 1 << 18;
146
+ var SLUG_ALL_LINEAR_BIT = 16384;
147
+ var SLUG_LINEAR_EPS = 1e-6;
148
+ function packBandRow(curveStart, count, bandUMin, bandUMax, uMinGlyph, uMaxGlyph, uInvSpan, allLinear, vec4Curves) {
149
+ const shift = vec4Curves ? 15 : 14;
150
+ const limit = vec4Curves ? SLUG_CURVE_START_LIMIT : SLUG_CURVE_START_LIMIT_VEC2;
151
+ if (curveStart >= limit) throw new RangeError(`Slug curve buffer exceeded ${vec4Curves ? 17 : 18}-bit band start limit (${curveStart} >= ${limit})`);
152
+ const linearBit = vec4Curves && allLinear ? SLUG_ALL_LINEAR_BIT : 0;
153
+ if (count === 0 || uInvSpan <= 0) return (curveStart << shift | linearBit | count) >>> 0;
146
154
  const qMin = Math.max(0, Math.min(15, Math.floor((bandUMin - uMinGlyph) * uInvSpan * 16 - .001)));
147
- const qMax = Math.max(0, Math.min(3, Math.floor((uMaxGlyph - bandUMax) * uInvSpan * 4 - .001)));
148
- return curveStart << 12 | qMax << 10 | qMin << 6 | safeCount;
155
+ const qMax = Math.max(0, Math.min(15, Math.floor((uMaxGlyph - bandUMax) * uInvSpan * 16 - .001)));
156
+ return (curveStart << shift | linearBit | qMax << 10 | qMin << 6 | count) >>> 0;
149
157
  }
150
- function emitDirectionalBands(pieces, bucketData, bucketCounts, bucketStride, bandCount, bandOrigin, bandStep, epsOrtho, uMinGlyph, uMaxGlyph, uInvSpan, rotated, packed) {
158
+ function emitDirectionalBands(pieces, bucketData, bucketCounts, bucketStride, bandCount, bandOrigin, bandStep, epsOrtho, uMinGlyph, uMaxGlyph, uInvSpan, rotated, vec4Curves, packed) {
151
159
  let bandedPieces = 0;
152
- const rows = ensureSlugRowCapacity(packed.rowLen + bandCount, packed.rowLen);
160
+ let rowLen = packed.rowLen;
161
+ let curveLen = packed.curveLen;
162
+ const rows = ensureSlugRowCapacity(rowLen + bandCount, rowLen);
163
+ const startShift = vec4Curves ? 15 : 14;
164
+ const startLimit = vec4Curves ? SLUG_CURVE_START_LIMIT : SLUG_CURVE_START_LIMIT_VEC2;
153
165
  for (let band = 0; band < bandCount; band++) {
154
166
  const count = bucketCounts[band];
155
- const curveStart = packed.curveLen >>> 1;
167
+ const curveStart = (vec4Curves ? curveLen >>> 2 : curveLen >>> 1) + packed.curveStartOffset;
168
+ const emptyRow = curveStart >= startLimit ? 0 : curveStart << startShift >>> 0;
156
169
  if (count === 0) {
157
- rows[packed.rowLen++] = curveStart << 12;
170
+ rows[rowLen++] = emptyRow;
158
171
  continue;
159
172
  }
160
- if (bandRayMaxScratch.length < count) {
161
- let size = bandRayMaxScratch.length;
162
- while (size < count) size *= 2;
163
- bandRayMaxScratch = new Float32Array(size);
164
- bandClippedScratch = new Float32Array(size * 6);
165
- descOrder = new Int32Array(size);
166
- }
167
173
  const vLo = bandOrigin + band * bandStep - epsOrtho;
168
174
  const vHi = bandOrigin + (band + 1) * bandStep + epsOrtho;
169
175
  const bucketBase = band * bucketStride;
170
176
  let bandUMin = Infinity;
177
+ let emitted = 0;
171
178
  for (let i = 0; i < count; i++) {
172
- const offset = bucketData[bucketBase + i] * 6;
179
+ const pieceIdx = bucketData[bucketBase + i];
180
+ const offset = pieceIdx * 6;
173
181
  const u0 = rotated ? pieces[offset + 1] : pieces[offset];
174
182
  const v0 = rotated ? -pieces[offset] : pieces[offset + 1];
175
183
  const uc = rotated ? pieces[offset + 3] : pieces[offset + 2];
@@ -177,37 +185,44 @@ function emitDirectionalBands(pieces, bucketData, bucketCounts, bucketStride, ba
177
185
  const u1 = rotated ? pieces[offset + 5] : pieces[offset + 4];
178
186
  const v1 = rotated ? -pieces[offset + 4] : pieces[offset + 5];
179
187
  let q0u = u0, q0v = v0, q1u = uc, q1v = vc, q2u = u1, q2v = v1;
180
- if (bandCount > 1 && bandStep > 0 && !(u0 === u1 && u0 === uc)) {
181
- const rising = v0 < v1;
182
- const collinear = Math.abs(u0 - 2 * uc + u1) <= 1e-7 && Math.abs(v0 - 2 * vc + v1) <= 1e-7;
183
- let ta;
184
- let tb;
185
- if (collinear && v1 !== v0) {
186
- const invDv = 1 / (v1 - v0);
187
- ta = rising ? v0 < vLo ? Math.min(Math.max((vLo - v0) * invDv, 0), 1) : 0 : v0 > vHi ? Math.min(Math.max((vHi - v0) * invDv, 0), 1) : 0;
188
- tb = rising ? v1 > vHi ? Math.min(Math.max((vHi - v0) * invDv, 0), 1) : 1 : v1 < vLo ? Math.min(Math.max((vLo - v0) * invDv, 0), 1) : 1;
189
- } else {
190
- ta = rising ? v0 < vLo ? solveMonotoneT(v0, vc, v1, vLo) : 0 : v0 > vHi ? solveMonotoneT(v0, vc, v1, vHi) : 0;
191
- tb = rising ? v1 > vHi ? solveMonotoneT(v0, vc, v1, vHi) : 1 : v1 < vLo ? solveMonotoneT(v0, vc, v1, vLo) : 1;
192
- }
193
- if ((ta > 0 || tb < 1) && tb > ta) {
194
- if (collinear) {
195
- const du = u1 - u0;
196
- q0u = Math.fround(u0 + du * ta);
197
- q0v = Math.fround(ta === 0 ? v0 : rising ? vLo : vHi);
198
- q2u = Math.fround(u0 + du * tb);
199
- q2v = Math.fround(tb === 1 ? v1 : rising ? vHi : vLo);
200
- q1u = Math.fround((q0u + q2u) * .5);
201
- q1v = Math.fround((q0v + q2v) * .5);
188
+ const vMin = v0 < v1 ? v0 : v1;
189
+ const vMax = v0 < v1 ? v1 : v0;
190
+ const collinear = collinearScratch[pieceIdx] === 1;
191
+ if (bandCount > 1 && bandStep > 0) {
192
+ if (vMax <= vLo || vMin >= vHi) continue;
193
+ if (!(u0 === u1 && u0 === uc) && (vMin < vLo || vMax > vHi)) {
194
+ const rising = v0 < v1;
195
+ let ta;
196
+ let tb;
197
+ if (collinear && v1 !== v0) {
198
+ const invDv = 1 / (v1 - v0);
199
+ ta = rising ? v0 < vLo ? Math.min(Math.max((vLo - v0) * invDv, 0), 1) : 0 : v0 > vHi ? Math.min(Math.max((vHi - v0) * invDv, 0), 1) : 0;
200
+ tb = rising ? v1 > vHi ? Math.min(Math.max((vHi - v0) * invDv, 0), 1) : 1 : v1 < vLo ? Math.min(Math.max((vLo - v0) * invDv, 0), 1) : 1;
202
201
  } else {
203
- const ua = 1 - ta;
204
- const ub = 1 - tb;
205
- q0u = ua * ua * u0 + 2 * ua * ta * uc + ta * ta * u1;
206
- q0v = ta === 0 ? v0 : rising ? vLo : vHi;
207
- q2u = ub * ub * u0 + 2 * ub * tb * uc + tb * tb * u1;
208
- q2v = tb === 1 ? v1 : rising ? vHi : vLo;
209
- q1u = ua * ub * u0 + (ua * tb + ta * ub) * uc + ta * tb * u1;
210
- q1v = ua * ub * v0 + (ua * tb + ta * ub) * vc + ta * tb * v1;
202
+ ta = rising ? v0 < vLo ? solveMonotoneT(v0, vc, v1, vLo) : 0 : v0 > vHi ? solveMonotoneT(v0, vc, v1, vHi) : 0;
203
+ tb = rising ? v1 > vHi ? solveMonotoneT(v0, vc, v1, vHi) : 1 : v1 < vLo ? solveMonotoneT(v0, vc, v1, vLo) : 1;
204
+ }
205
+ if (!(tb > ta)) continue;
206
+ if (ta > 0 || tb < 1) {
207
+ if (collinear) {
208
+ const du = u1 - u0;
209
+ q0u = Math.fround(u0 + du * ta);
210
+ q0v = Math.fround(ta === 0 ? v0 : rising ? vLo : vHi);
211
+ q2u = Math.fround(u0 + du * tb);
212
+ q2v = Math.fround(tb === 1 ? v1 : rising ? vHi : vLo);
213
+ q1u = (q0u + q2u) * .5;
214
+ q1v = (q0v + q2v) * .5;
215
+ } else {
216
+ const ua = 1 - ta;
217
+ const ub = 1 - tb;
218
+ q0u = ua * ua * u0 + 2 * ua * ta * uc + ta * ta * u1;
219
+ q0v = ta === 0 ? v0 : rising ? vLo : vHi;
220
+ q2u = ub * ub * u0 + 2 * ub * tb * uc + tb * tb * u1;
221
+ q2v = tb === 1 ? v1 : rising ? vHi : vLo;
222
+ q1u = ua * ub * u0 + (ua * tb + ta * ub) * uc + ta * tb * u1;
223
+ q1v = ua * ub * v0 + (ua * tb + ta * ub) * vc + ta * tb * v1;
224
+ }
225
+ if (Math.fround(q0v) === Math.fround(q2v)) continue;
211
226
  }
212
227
  }
213
228
  }
@@ -220,70 +235,46 @@ function emitDirectionalBands(pieces, bucketData, bucketCounts, bucketStride, ba
220
235
  if (q1v < pieceVMin) q1v = pieceVMin;
221
236
  else if (q1v > pieceVMax) q1v = pieceVMax;
222
237
  if (pieceUMin < bandUMin) bandUMin = pieceUMin;
223
- if (count === 1) {
224
- const curves = ensureSlugCurveCapacity(packed.curveLen + 6, packed.curveLen);
225
- const w = packed.curveLen;
226
- curves[w] = q0u;
227
- curves[w + 1] = q0v;
228
- curves[w + 2] = q2u;
229
- curves[w + 3] = q2v;
230
- curves[w + 4] = q1u;
231
- curves[w + 5] = q1v;
232
- packed.curveLen = w + 6;
233
- rows[packed.rowLen++] = packBandRow(curveStart, 1, bandUMin, pieceUMax, uMinGlyph, uMaxGlyph, uInvSpan);
234
- bandedPieces += 1;
235
- break;
236
- }
237
- const outOffset = i * 6;
238
+ const key = Math.fround(pieceUMax);
239
+ let slot = emitted;
240
+ let j = emitted;
241
+ if (emitted >= MAX_ROW_CURVES) {
242
+ j = 62;
243
+ if (key <= bandRayMaxScratch[j]) continue;
244
+ slot = descOrder[j];
245
+ } else emitted++;
246
+ const linear = collinear || Math.fround(q0u) === Math.fround(q2u) || Math.abs(q0u - 2 * q1u + q2u) <= SLUG_LINEAR_EPS && Math.abs(q0v - 2 * q1v + q2v) <= SLUG_LINEAR_EPS;
247
+ const outOffset = slot * 6;
238
248
  bandClippedScratch[outOffset] = q0u;
239
249
  bandClippedScratch[outOffset + 1] = q0v;
240
250
  bandClippedScratch[outOffset + 2] = q2u;
241
251
  bandClippedScratch[outOffset + 3] = q2v;
242
252
  bandClippedScratch[outOffset + 4] = q1u;
243
253
  bandClippedScratch[outOffset + 5] = q1v;
244
- bandRayMaxScratch[i] = pieceUMax;
245
- descOrder[i] = i;
254
+ bandLinearScratch[slot] = linear ? 1 : 0;
255
+ while (j > 0 && bandRayMaxScratch[j - 1] < key) {
256
+ bandRayMaxScratch[j] = bandRayMaxScratch[j - 1];
257
+ descOrder[j] = descOrder[j - 1];
258
+ j--;
259
+ }
260
+ bandRayMaxScratch[j] = key;
261
+ descOrder[j] = slot;
246
262
  }
247
- if (count === 1) continue;
248
- if (count === 2) {
249
- const curves = ensureSlugCurveCapacity(packed.curveLen + 12, packed.curveLen);
250
- const w = packed.curveLen;
251
- const r0 = bandRayMaxScratch[0];
252
- const r1 = bandRayMaxScratch[1];
253
- const firstOff = r0 >= r1 ? 0 : 6;
254
- const secondOff = 6 - firstOff;
255
- curves[w] = bandClippedScratch[firstOff];
256
- curves[w + 1] = bandClippedScratch[firstOff + 1];
257
- curves[w + 2] = bandClippedScratch[firstOff + 2];
258
- curves[w + 3] = bandClippedScratch[firstOff + 3];
259
- curves[w + 4] = bandClippedScratch[secondOff];
260
- curves[w + 5] = bandClippedScratch[secondOff + 1];
261
- curves[w + 6] = bandClippedScratch[secondOff + 2];
262
- curves[w + 7] = bandClippedScratch[secondOff + 3];
263
- curves[w + 8] = bandClippedScratch[firstOff + 4];
264
- curves[w + 9] = bandClippedScratch[firstOff + 5];
265
- curves[w + 10] = bandClippedScratch[secondOff + 4];
266
- curves[w + 11] = bandClippedScratch[secondOff + 5];
267
- packed.curveLen = w + 12;
268
- rows[packed.rowLen++] = packBandRow(curveStart, 2, bandUMin, r0 >= r1 ? r0 : r1, uMinGlyph, uMaxGlyph, uInvSpan);
269
- bandedPieces += 2;
263
+ if (emitted === 0) {
264
+ rows[rowLen++] = emptyRow;
270
265
  continue;
271
266
  }
272
- for (let i = 1; i < count; i++) {
273
- const idx = descOrder[i];
274
- const key = bandRayMaxScratch[i];
275
- let j = i - 1;
276
- while (j >= 0 && bandRayMaxScratch[j] < key) {
277
- bandRayMaxScratch[j + 1] = bandRayMaxScratch[j];
278
- descOrder[j + 1] = descOrder[j];
279
- j--;
267
+ const emitCount = emitted;
268
+ let allLinear = vec4Curves;
269
+ if (allLinear) {
270
+ for (let i = 0; i < emitCount; i++) if (!bandLinearScratch[i]) {
271
+ allLinear = false;
272
+ break;
280
273
  }
281
- bandRayMaxScratch[j + 1] = key;
282
- descOrder[j + 1] = idx;
283
274
  }
284
- const emitCount = count > 63 ? 63 : count;
285
- const curves = ensureSlugCurveCapacity(packed.curveLen + emitCount * 6, packed.curveLen);
286
- let curveWrite = packed.curveLen;
275
+ const c2Floats = vec4Curves ? allLinear ? 0 : (emitCount + 1 >>> 1) * 4 : emitCount * 2;
276
+ const curves = ensureSlugCurveCapacity(curveLen + emitCount * 4 + c2Floats, curveLen);
277
+ let curveWrite = curveLen;
287
278
  for (let i = 0; i < emitCount; i++) {
288
279
  const outOffset = descOrder[i] * 6;
289
280
  curves[curveWrite] = bandClippedScratch[outOffset];
@@ -292,25 +283,35 @@ function emitDirectionalBands(pieces, bucketData, bucketCounts, bucketStride, ba
292
283
  curves[curveWrite + 3] = bandClippedScratch[outOffset + 3];
293
284
  curveWrite += 4;
294
285
  }
295
- for (let i = 0; i < emitCount; i++) {
296
- const outOffset = descOrder[i] * 6;
297
- curves[curveWrite] = bandClippedScratch[outOffset + 4];
298
- curves[curveWrite + 1] = bandClippedScratch[outOffset + 5];
299
- curveWrite += 2;
286
+ if (!allLinear) {
287
+ for (let i = 0; i < emitCount; i++) {
288
+ const outOffset = descOrder[i] * 6;
289
+ curves[curveWrite] = bandClippedScratch[outOffset + 4];
290
+ curves[curveWrite + 1] = bandClippedScratch[outOffset + 5];
291
+ curveWrite += 2;
292
+ }
293
+ if (vec4Curves && (emitCount & 1) !== 0) {
294
+ curves[curveWrite] = 0;
295
+ curves[curveWrite + 1] = 0;
296
+ curveWrite += 2;
297
+ }
300
298
  }
301
- packed.curveLen = curveWrite;
302
- rows[packed.rowLen++] = packBandRow(curveStart, emitCount, bandUMin, bandRayMaxScratch[0], uMinGlyph, uMaxGlyph, uInvSpan);
299
+ curveLen = curveWrite;
300
+ rows[rowLen++] = packBandRow(curveStart, emitCount, bandUMin, bandRayMaxScratch[0], uMinGlyph, uMaxGlyph, uInvSpan, allLinear, vec4Curves);
303
301
  bandedPieces += emitCount;
304
302
  }
303
+ packed.rowLen = rowLen;
304
+ packed.curveLen = curveLen;
305
305
  return bandedPieces;
306
306
  }
307
- function buildSlugBands(quadratics, bbox, targetPiecesPerBand, packed, signal) {
307
+ function buildSlugBands(quadratics, bbox, targetPiecesPerBand, vec4Curves, packed, signal) {
308
308
  const pieceLen = splitOutline(quadratics, signal);
309
309
  const pieces = scratchPieces;
310
310
  const monotonePieceCount = pieceLen / 6;
311
311
  const rowBase = packed.rowLen;
312
312
  if (monotonePieceCount === 0) {
313
- const emptyRow = packed.curveLen >>> 1 << 12;
313
+ const emptyStart = (vec4Curves ? packed.curveLen >>> 2 : packed.curveLen >>> 1) + packed.curveStartOffset;
314
+ const emptyRow = vec4Curves ? emptyStart >= SLUG_CURVE_START_LIMIT ? 0 : emptyStart << 15 >>> 0 : emptyStart >= SLUG_CURVE_START_LIMIT_VEC2 ? 0 : emptyStart << 14 >>> 0;
314
315
  const rows = ensureSlugRowCapacity(packed.rowLen + 2, packed.rowLen);
315
316
  rows[packed.rowLen++] = emptyRow;
316
317
  rows[packed.rowLen++] = emptyRow;
@@ -332,6 +333,7 @@ function buildSlugBands(quadratics, bbox, targetPiecesPerBand, packed, signal) {
332
333
  yMinScratch = new Float32Array(size);
333
334
  yMaxScratch = new Float32Array(size);
334
335
  spanFlagsScratch = new Uint8Array(size);
336
+ collinearScratch = new Uint8Array(size);
335
337
  }
336
338
  if (bucketCapacity < monotonePieceCount) {
337
339
  while (bucketCapacity < monotonePieceCount) bucketCapacity *= 2;
@@ -340,15 +342,22 @@ function buildSlugBands(quadratics, bbox, targetPiecesPerBand, packed, signal) {
340
342
  }
341
343
  let hActivePieces = 0;
342
344
  let vActivePieces = 0;
345
+ const isFloat32Input = quadratics instanceof Float32Array;
343
346
  for (let i = 0; i < monotonePieceCount; i++) {
344
347
  const offset = i * 6;
345
- const x0 = pieces[offset], y0 = pieces[offset + 1], x1 = pieces[offset + 4], y1 = pieces[offset + 5];
346
- xMinScratch[i] = x0 < x1 ? x0 : x1;
347
- xMaxScratch[i] = x0 > x1 ? x0 : x1;
348
- yMinScratch[i] = y0 < y1 ? y0 : y1;
349
- yMaxScratch[i] = y0 > y1 ? y0 : y1;
350
- const hActive = yMinScratch[i] !== yMaxScratch[i] ? 1 : 0;
351
- const vActive = xMinScratch[i] !== xMaxScratch[i] ? 2 : 0;
348
+ const x0 = pieces[offset], y0 = pieces[offset + 1], cx = pieces[offset + 2], cy = pieces[offset + 3], x1 = pieces[offset + 4], y1 = pieces[offset + 5];
349
+ const xMinF = Math.fround(x0 < x1 ? x0 : x1);
350
+ const xMaxF = Math.fround(x0 > x1 ? x0 : x1);
351
+ const yMinF = Math.fround(y0 < y1 ? y0 : y1);
352
+ const yMaxF = Math.fround(y0 > y1 ? y0 : y1);
353
+ xMinScratch[i] = xMinF;
354
+ xMaxScratch[i] = xMaxF;
355
+ yMinScratch[i] = yMinF;
356
+ yMaxScratch[i] = yMaxF;
357
+ const isLine = Math.abs(x0 - 2 * cx + x1) <= 1e-7 && Math.abs(y0 - 2 * cy + y1) <= 1e-7 || isFloat32Input && cx === Math.fround((x0 + x1) * .5) && cy === Math.fround((y0 + y1) * .5);
358
+ collinearScratch[i] = isLine ? 1 : 0;
359
+ const hActive = yMinF !== yMaxF ? 1 : 0;
360
+ const vActive = xMinF !== xMaxF ? 2 : 0;
352
361
  spanFlagsScratch[i] = hActive | vActive;
353
362
  hActivePieces += hActive;
354
363
  vActivePieces += vActive >>> 1;
@@ -367,11 +376,22 @@ function buildSlugBands(quadratics, bbox, targetPiecesPerBand, packed, signal) {
367
376
  vBucketCounts.fill(0, 0, vBandCount);
368
377
  const rotY0 = -bbox[2];
369
378
  const stride = bucketCapacity;
379
+ const hOrigin = bbox[1];
380
+ const hMax = hBandCount - 1;
381
+ const vMax = vBandCount - 1;
382
+ const hasHInv = invH > 0;
383
+ const hasVInv = invW > 0;
370
384
  for (let i = 0; i < monotonePieceCount; i++) {
371
385
  const flags = spanFlagsScratch[i];
372
386
  if (flags & 1) {
373
- const firstH = hBandCount > 1 ? bandIndex(yMinScratch[i] - epsY, bbox[1], invH, hBandCount) : 0;
374
- const lastH = hBandCount > 1 ? bandIndex(yMaxScratch[i] + epsY, bbox[1], invH, hBandCount) : 0;
387
+ let firstH = 0;
388
+ let lastH = 0;
389
+ if (hBandCount > 1 && hasHInv) {
390
+ const f = Math.floor((yMinScratch[i] - epsY - hOrigin) * invH);
391
+ const l = Math.floor((yMaxScratch[i] + epsY - hOrigin) * invH);
392
+ firstH = f < 0 ? 0 : f > hMax ? hMax : f;
393
+ lastH = l < 0 ? 0 : l > hMax ? hMax : l;
394
+ }
375
395
  for (let band = firstH; band <= lastH; band++) {
376
396
  const idx = hBucketCounts[band];
377
397
  hBucketData[band * stride + idx] = i;
@@ -379,8 +399,14 @@ function buildSlugBands(quadratics, bbox, targetPiecesPerBand, packed, signal) {
379
399
  }
380
400
  }
381
401
  if (flags & 2) {
382
- const firstV = vBandCount > 1 ? bandIndex(-xMaxScratch[i] - epsX, rotY0, invW, vBandCount) : 0;
383
- const lastV = vBandCount > 1 ? bandIndex(-xMinScratch[i] + epsX, rotY0, invW, vBandCount) : 0;
402
+ let firstV = 0;
403
+ let lastV = 0;
404
+ if (vBandCount > 1 && hasVInv) {
405
+ const f = Math.floor((-xMaxScratch[i] - epsX - rotY0) * invW);
406
+ const l = Math.floor((-xMinScratch[i] + epsX - rotY0) * invW);
407
+ firstV = f < 0 ? 0 : f > vMax ? vMax : f;
408
+ lastV = l < 0 ? 0 : l > vMax ? vMax : l;
409
+ }
384
410
  for (let band = firstV; band <= lastV; band++) {
385
411
  const idx = vBucketCounts[band];
386
412
  vBucketData[band * stride + idx] = i;
@@ -388,8 +414,8 @@ function buildSlugBands(quadratics, bbox, targetPiecesPerBand, packed, signal) {
388
414
  }
389
415
  }
390
416
  }
391
- const hBanded = emitDirectionalBands(pieces, hBucketData, hBucketCounts, stride, hBandCount, bbox[1], height > 0 ? height / hBandCount : 0, epsY, bbox[0], bbox[2], invSpanX, false, packed);
392
- const vBanded = emitDirectionalBands(pieces, vBucketData, vBucketCounts, stride, vBandCount, rotY0, width > 0 ? width / vBandCount : 0, epsX, bbox[1], bbox[3], invSpanY, true, packed);
417
+ const hBanded = emitDirectionalBands(pieces, hBucketData, hBucketCounts, stride, hBandCount, bbox[1], height > 0 ? height / hBandCount : 0, epsY, bbox[0], bbox[2], invSpanX, false, vec4Curves, packed);
418
+ const vBanded = emitDirectionalBands(pieces, vBucketData, vBucketCounts, stride, vBandCount, rotY0, width > 0 ? width / vBandCount : 0, epsX, bbox[1], bbox[3], invSpanY, true, vec4Curves, packed);
393
419
  return {
394
420
  rowBase,
395
421
  bandCount: hBandCount | vBandCount << 8,
@@ -403,19 +429,21 @@ function buildSlugBands(quadratics, bbox, targetPiecesPerBand, packed, signal) {
403
429
  function readQuadraticsFast(value, label) {
404
430
  if (value instanceof Float32Array) {
405
431
  let check = 0;
406
- for (let i = 0, len = value.length; i < len; i++) {
407
- const v = value[i];
408
- check += v - v;
432
+ const len = value.length;
433
+ let i = 0;
434
+ for (const end = len - 3; i < end; i += 4) {
435
+ const v0 = value[i];
436
+ const v1 = value[i + 1];
437
+ const v2 = value[i + 2];
438
+ const v3 = value[i + 3];
439
+ check += v0 - v0 + (v1 - v1) + (v2 - v2) + (v3 - v3);
409
440
  }
410
- if (!Number.isNaN(check)) return value;
411
- } else if (value instanceof Float64Array) {
412
- let check = 0;
413
- for (let i = 0, len = value.length; i < len; i++) {
414
- const v = Math.fround(value[i]);
441
+ for (; i < len; i++) {
442
+ const v = value[i];
415
443
  check += v - v;
416
444
  }
417
445
  if (!Number.isNaN(check)) return value;
418
- } else if (Array.isArray(value)) {
446
+ } else if (value instanceof Float64Array || Array.isArray(value)) {
419
447
  const list = value;
420
448
  let valid = true;
421
449
  for (let i = 0, len = list.length; i < len; i++) {
@@ -483,10 +511,13 @@ function outlinesEqual(left, right) {
483
511
  * bands with endpoint-first `[p1, p3, p2]` layout and orthogonal degenerate culling.
484
512
  */
485
513
  function preprocessSlugGlyphs(sources, options = {}) {
514
+ return preprocessSlugGlyphsBatch(sources, options, 0, 0);
515
+ }
516
+ function preprocessSlugGlyphsBatch(sources, options = {}, curveFloatOffset = 0, rowUintOffset = 0) {
486
517
  throwIfAborted(options.signal);
487
518
  if (!Array.isArray(sources)) throw new TypeError("sources must be an array of SlugGlyphSource records");
488
- const targetPiecesPerBand = options.targetPiecesPerBand === void 0 ? 2 : readFiniteFloat32(options.targetPiecesPerBand, "options.targetPiecesPerBand");
489
- if (!Number.isInteger(targetPiecesPerBand) || targetPiecesPerBand <= 0) throw new RangeError("options.targetPiecesPerBand must be a positive integer");
519
+ const targetPiecesPerBand = options.targetPiecesPerBand === void 0 ? SLUG_TARGET_PIECES_PER_BAND : readFiniteFloat32(options.targetPiecesPerBand, "options.targetPiecesPerBand");
520
+ if (!(targetPiecesPerBand > 0)) throw new RangeError("options.targetPiecesPerBand must be a positive number");
490
521
  const uniqueByKey = /* @__PURE__ */ new Map();
491
522
  const uniqueRaw = /* @__PURE__ */ new Map();
492
523
  for (let index = 0; index < sources.length; index++) {
@@ -506,10 +537,28 @@ function preprocessSlugGlyphs(sources, options = {}) {
506
537
  uniqueByKey.set(key, outline);
507
538
  uniqueRaw.set(key, raw.outline);
508
539
  }
540
+ const vec4Curves = options.vec4Curves !== false;
541
+ if (vec4Curves && (curveFloatOffset & 3) !== 0) throw new RangeError("curveFloatOffset must be a multiple of 4 for vec4 Slug curves");
542
+ if (!vec4Curves && (curveFloatOffset & 1) !== 0) throw new RangeError("curveFloatOffset must be a multiple of 2 for vec2 Slug curves");
509
543
  const sortedKeys = [...uniqueByKey.keys()].sort();
544
+ let estimatedQuadFloats = 0;
545
+ let estimatedLayers = 0;
546
+ for (const key of sortedKeys) {
547
+ const outline = uniqueByKey.get(key);
548
+ if (outline.layers !== void 0) {
549
+ estimatedLayers += outline.layers.length;
550
+ for (const layer of outline.layers) estimatedQuadFloats += layer.quadratics.length;
551
+ } else {
552
+ estimatedLayers++;
553
+ estimatedQuadFloats += outline.quadratics.length;
554
+ }
555
+ }
556
+ ensureSlugCurveCapacity(Math.ceil(estimatedQuadFloats * 4.5), 0);
557
+ ensureSlugRowCapacity(estimatedLayers * 16, 0);
510
558
  const packed = {
511
559
  curveLen: 0,
512
- rowLen: 0
560
+ rowLen: 0,
561
+ curveStartOffset: vec4Curves ? curveFloatOffset >>> 2 : curveFloatOffset >>> 1
513
562
  };
514
563
  const glyphs = /* @__PURE__ */ new Map();
515
564
  let totalMonotonePieces = 0;
@@ -525,14 +574,14 @@ function preprocessSlugGlyphs(sources, options = {}) {
525
574
  const layerHeaders = [];
526
575
  let glyphPieces = 0;
527
576
  for (const layer of outline.layers) {
528
- const built = buildSlugBands(layer.quadratics, layer.bbox, targetPiecesPerBand, packed, options.signal);
577
+ const built = buildSlugBands(layer.quadratics, layer.bbox, targetPiecesPerBand, vec4Curves, packed, options.signal);
529
578
  glyphPieces += built.monotonePieceCount;
530
579
  totalMonotonePieces += built.monotonePieceCount;
531
580
  totalBands += built.bandRows;
532
581
  totalBandedPieces += built.bandedPieces;
533
582
  totalPaintLayers++;
534
583
  layerHeaders.push({
535
- rowBase: built.rowBase,
584
+ rowBase: built.rowBase + rowUintOffset,
536
585
  bandCount: built.bandCount,
537
586
  bandH: built.bandH,
538
587
  invH: built.invH,
@@ -546,7 +595,7 @@ function preprocessSlugGlyphs(sources, options = {}) {
546
595
  }
547
596
  const first = layerHeaders[0];
548
597
  glyphs.set(key, {
549
- rowBase: first?.rowBase ?? packed.rowLen,
598
+ rowBase: first?.rowBase ?? packed.rowLen + rowUintOffset,
550
599
  bandCount: first ? 1 : 0,
551
600
  bandH: first?.bandH ?? 0,
552
601
  invH: first?.invH ?? 0,
@@ -560,13 +609,13 @@ function preprocessSlugGlyphs(sources, options = {}) {
560
609
  });
561
610
  continue;
562
611
  }
563
- const built = buildSlugBands(outline.quadratics, outline.bbox, targetPiecesPerBand, packed, options.signal);
612
+ const built = buildSlugBands(outline.quadratics, outline.bbox, targetPiecesPerBand, vec4Curves, packed, options.signal);
564
613
  totalMonotonePieces += built.monotonePieceCount;
565
614
  totalBands += built.bandRows;
566
615
  totalBandedPieces += built.bandedPieces;
567
616
  if (built.monotonePieceCount > 0) totalPaintLayers++;
568
617
  glyphs.set(key, {
569
- rowBase: built.rowBase,
618
+ rowBase: built.rowBase + rowUintOffset,
570
619
  bandCount: built.bandCount,
571
620
  bandH: built.bandH,
572
621
  invH: built.invH,
@@ -578,7 +627,7 @@ function preprocessSlugGlyphs(sources, options = {}) {
578
627
  ...outline.clipBox ? { clipBox: outline.clipBox } : {}
579
628
  });
580
629
  }
581
- return {
630
+ const result = {
582
631
  layered,
583
632
  curves: scratchCurves.slice(0, packed.curveLen),
584
633
  rows: scratchRows.slice(0, packed.rowLen),
@@ -592,7 +641,9 @@ function preprocessSlugGlyphs(sources, options = {}) {
592
641
  duplication: totalMonotonePieces > 0 ? totalBandedPieces / totalMonotonePieces : 0
593
642
  }
594
643
  };
644
+ if (!vec4Curves) Object.defineProperty(result, Symbol.for("ultraTextVec2Curves"), { value: true });
645
+ return result;
595
646
  }
596
- export { preprocessSlugGlyphs };
647
+ export { SLUG_TARGET_PIECES_PER_BAND, preprocessSlugGlyphs, preprocessSlugGlyphsBatch };
597
648
 
598
649
  //# sourceMappingURL=preprocessCore.js.map