@weasel-js/text 1.14.1 → 1.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-FODNMBHI.js → chunk-ZNSU5C43.js} +536 -400
- package/dist/chunk-ZNSU5C43.js.map +1 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +58 -29
- package/dist/index.js.map +1 -1
- package/dist/{test-seams-DHGfE_6p.d.ts → test-seams-Ck0mfD3U.d.ts} +34 -1
- package/dist/test-seams.d.ts +1 -1
- package/dist/test-seams.js +1 -1
- package/package.json +6 -6
- package/dist/chunk-FODNMBHI.js.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { S as StyledRun, T as TextStyle, L as LaidOutRuns, R as ResolvedTextStyle, a as ResolvedRun, b as LayoutRunsOpts, c as TextShaper, C as CacheUse, d as TextPaint, P as PlacedGlyph } from './test-seams-
|
|
2
|
-
export { B as BidiAnalysis, e as BidiReordering, f as BidiResolver, D as DEFAULT_TEXT_FILL, g as DEFAULT_TEXT_STYLE, F as FontVariantCaps, h as LAYOUT_CACHE_STRUCTURAL_LIMIT, i as LAYOUT_CACHE_VARIANT_LIMIT, j as LaidOutCell, k as LaidOutLineBox, M as MARKDOWN_RUN_GRAMMAR, l as RunFlag, m as RunGrammar, n as RunMarker, o as RunSourceMap, p as SCRIPT_METRICS, q as SMALL_CAPS_SCALE, r as ScriptPreset, s as ShapedCluster, t as ShapedGlyph, u as SmallCapsText, v as TextAlign, w as TextDirection, x as TextTransform, y as TransformedRunText, z as cachedLayoutRuns, A as
|
|
1
|
+
import { S as StyledRun, T as TextStyle, L as LaidOutRuns, R as ResolvedTextStyle, a as ResolvedRun, b as LayoutRunsOpts, c as TextShaper, C as CacheUse, d as TextPaint, P as PlacedGlyph } from './test-seams-Ck0mfD3U.js';
|
|
2
|
+
export { B as BidiAnalysis, e as BidiReordering, f as BidiResolver, D as DEFAULT_TEXT_FILL, g as DEFAULT_TEXT_STYLE, F as FontVariantCaps, h as LAYOUT_CACHE_STRUCTURAL_LIMIT, i as LAYOUT_CACHE_VARIANT_LIMIT, j as LaidOutCell, k as LaidOutLineBox, M as MARKDOWN_RUN_GRAMMAR, l as RunFlag, m as RunGrammar, n as RunMarker, o as RunSourceMap, p as SCRIPT_METRICS, q as SMALL_CAPS_SCALE, r as ScriptPreset, s as ShapedCluster, t as ShapedGlyph, u as SmallCapsText, v as TextAlign, w as TextDirection, x as TextTransform, y as TransformedRunText, z as cachedLayoutRuns, A as clearRuns, E as dropRuns, G as fontString, H as halfLeadingFor, I as isBoldWeight, J as isSmallCapsLetter, K as layoutRuns, N as markdownToRuns, O as numericWeight, Q as paragraphDirection, U as registerBidi, V as registeredBidi, W as resolveAlign, X as resolveRunFace, Y as resolveRuns, Z as resolveRunsInto, _ as resolveTextStyle, $ as resolveTextStyleInto, a0 as runsToMarkdown, a1 as runsToPlainText, a2 as scriptMetrics, a3 as scriptMetricsFor, a4 as smallCapsScale, a5 as smallCapsScaleFor, a6 as smallCapsText, a7 as toRuns, a8 as transformRunTexts, a9 as warnRtlWithoutEngine } from './test-seams-Ck0mfD3U.js';
|
|
3
3
|
import { FaceRuleMetrics, FaceMetrics, BmFontChar, FontStyle, ResolveResult } from '@weasel-js/font';
|
|
4
4
|
import { Fill, Stroke } from '@weasel-js/paint';
|
|
5
5
|
import { Rect, PolygonPath, PathInWorldPose } from '@weasel-js/geom';
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { DEFAULT_TAB_SIZE, shapesWithFeature, resolveTextStyle, cachedLayoutRuns, graphemeCount, wrapLines, hangs, emboldenGlyph, layoutRuns, lineDecorations, runFaces, tabAdvance, widthWithTabs, DECORATION_KINDS, decorationRule, faceOutlineD, hasGlyphQuad } from './chunk-
|
|
2
|
-
export { BREAK_ALLOWED, BREAK_MANDATORY, DEFAULT_DECORATION_METRICS, DEFAULT_TEXT_FILL, DEFAULT_TEXT_STYLE, LAYOUT_CACHE_STRUCTURAL_LIMIT, LAYOUT_CACHE_VARIANT_LIMIT, NO_BREAK, QUAD_STRIDE, cachedLayoutRuns, cachedPaintRuns, decorationMetrics, dropRuns, emboldenGlyphD, fontString, isHardLineBreak, layoutRuns, lineBreakOpportunities, paintRuns, paragraphDirection, registerBidi, registerShaper, resolveAlign, resolveTextStyle, syntheticBoldOffset } from './chunk-
|
|
1
|
+
import { DEFAULT_TAB_SIZE, shapesWithFeature, resolveTextStyle, cachedLayoutRuns, graphemeCount, wrapLines, hangs, emboldenGlyph, layoutRuns, lineDecorations, runFaces, tabAdvance, widthWithTabs, DECORATION_KINDS, decorationRule, faceOutlineD, hasGlyphQuad } from './chunk-ZNSU5C43.js';
|
|
2
|
+
export { BREAK_ALLOWED, BREAK_MANDATORY, DEFAULT_DECORATION_METRICS, DEFAULT_TEXT_FILL, DEFAULT_TEXT_STYLE, LAYOUT_CACHE_STRUCTURAL_LIMIT, LAYOUT_CACHE_VARIANT_LIMIT, NO_BREAK, QUAD_STRIDE, cachedLayoutRuns, cachedPaintRuns, clearRuns, decorationMetrics, dropRuns, emboldenGlyphD, fontString, isHardLineBreak, layoutRuns, lineBreakOpportunities, paintRuns, paragraphDirection, registerBidi, registerShaper, registeredBidi, resolveAlign, resolveTextStyle, resolveTextStyleInto, syntheticBoldOffset, warnRtlWithoutEngine } from './chunk-ZNSU5C43.js';
|
|
3
3
|
import { resolveScreenLength, paintKey, strokeKey } from '@weasel-js/paint';
|
|
4
|
-
import { faceMetricsOf,
|
|
4
|
+
import { faceMetricsOf, cachedFontVariant, loadFontOutlines, glyphGeneration, faceMetricsFor, outlineStatus, cssFamilyName } from '@weasel-js/font';
|
|
5
5
|
import { MIXED, deepEqual } from '@weasel-js/registry';
|
|
6
6
|
export { MIXED } from '@weasel-js/registry';
|
|
7
7
|
import { transformPath, joinPaths, pathFromD, pathSignedArea, reversePath, poseFrameOf, originFor, coordsFrom, PATH_M, PATH_L, PATH_Z } from '@weasel-js/geom';
|
|
@@ -262,7 +262,7 @@ function smallCapsScale(face) {
|
|
|
262
262
|
return x / cap;
|
|
263
263
|
}
|
|
264
264
|
function smallCapsScaleFor(family, weight, style) {
|
|
265
|
-
return smallCapsScale(faceMetricsOf(
|
|
265
|
+
return smallCapsScale(faceMetricsOf(cachedFontVariant(family, weight, style)));
|
|
266
266
|
}
|
|
267
267
|
function isSmallCapsLetter(ch, lang) {
|
|
268
268
|
return ch.toLocaleUpperCase(caseLocale(lang)) !== ch;
|
|
@@ -317,10 +317,10 @@ function scriptMetrics(face) {
|
|
|
317
317
|
return out;
|
|
318
318
|
}
|
|
319
319
|
function scriptMetricsFor(family, weight, style) {
|
|
320
|
-
return scriptMetrics(faceMetricsOf(
|
|
320
|
+
return scriptMetrics(faceMetricsOf(cachedFontVariant(family, weight, style)));
|
|
321
321
|
}
|
|
322
322
|
function halfLeadingFor(family, weight, style, fontSize, lineHeight) {
|
|
323
|
-
const m = faceMetricsOf(
|
|
323
|
+
const m = faceMetricsOf(cachedFontVariant(family, weight, style));
|
|
324
324
|
if (m?.ascent === void 0 || m.descent === void 0) return void 0;
|
|
325
325
|
return (lineHeight - m.ascent - m.descent) / 2 * fontSize;
|
|
326
326
|
}
|
|
@@ -341,9 +341,11 @@ function resolveRunFace(run, style) {
|
|
|
341
341
|
fontStyle: run.italic ? "italic" : style.fontStyle
|
|
342
342
|
};
|
|
343
343
|
}
|
|
344
|
-
var NOTHING = Object.freeze({});
|
|
345
344
|
function resolveRuns(runs, style, viewScale = 1) {
|
|
346
|
-
|
|
345
|
+
return resolveRunsInto(new Array(runs.length), runs, style, viewScale);
|
|
346
|
+
}
|
|
347
|
+
function resolveRunsInto(out, runs, style, viewScale = 1) {
|
|
348
|
+
if (out.length !== runs.length) out.length = runs.length;
|
|
347
349
|
let transformed = false;
|
|
348
350
|
for (const r of runs) if ((r.textTransform ?? style.textTransform) !== "none") transformed = true;
|
|
349
351
|
const shown = transformed ? transformRunTexts(
|
|
@@ -377,29 +379,56 @@ function resolveRuns(runs, style, viewScale = 1) {
|
|
|
377
379
|
}
|
|
378
380
|
}
|
|
379
381
|
const lang = run.lang ?? style.lang;
|
|
380
|
-
|
|
382
|
+
const fill = run.fill !== void 0 ? run.fill : style.fill;
|
|
383
|
+
const letterSpacing = run.letterSpacing !== void 0 ? resolveScreenLength(run.letterSpacing, viewScale) : style.letterSpacing;
|
|
384
|
+
const underline = run.underline || style.underline;
|
|
385
|
+
const strikethrough = run.strikethrough || style.strikethrough;
|
|
386
|
+
const overline = run.overline || style.overline;
|
|
387
|
+
const stroke = run.stroke ?? style.stroke;
|
|
388
|
+
const rotate = run.rotate && Number.isFinite(run.rotate) ? run.rotate : void 0;
|
|
389
|
+
const prev = out[i];
|
|
390
|
+
if (prev !== void 0 && prev.srcMap !== void 0 === (srcMap !== void 0) && prev.sizeMap !== void 0 === (sizeMap !== void 0) && prev.stroke !== void 0 === (stroke !== void 0) && prev.strutSize !== void 0 === relative && prev.rotate !== void 0 === (rotate !== void 0) && prev.fontFeatures !== void 0 === (fontFeatures !== void 0) && prev.lang !== void 0 === !!lang) {
|
|
391
|
+
prev.text = text;
|
|
392
|
+
prev.fontFamily = fontFamily;
|
|
393
|
+
prev.fontSize = fontSize;
|
|
394
|
+
prev.fontWeight = fontWeight;
|
|
395
|
+
prev.fontStyle = fontStyle;
|
|
396
|
+
prev.fill = fill;
|
|
397
|
+
prev.letterSpacing = letterSpacing;
|
|
398
|
+
prev.underline = underline;
|
|
399
|
+
prev.strikethrough = strikethrough;
|
|
400
|
+
prev.overline = overline;
|
|
401
|
+
prev.baselineShift = shiftEm * style.fontSize;
|
|
402
|
+
if (srcMap) prev.srcMap = srcMap;
|
|
403
|
+
if (sizeMap) prev.sizeMap = sizeMap;
|
|
404
|
+
if (stroke !== void 0) prev.stroke = stroke;
|
|
405
|
+
if (relative) prev.strutSize = style.fontSize;
|
|
406
|
+
if (rotate !== void 0) prev.rotate = rotate;
|
|
407
|
+
if (fontFeatures) prev.fontFeatures = fontFeatures;
|
|
408
|
+
if (lang) prev.lang = lang;
|
|
409
|
+
continue;
|
|
410
|
+
}
|
|
411
|
+
const r = {
|
|
381
412
|
text,
|
|
382
|
-
...srcMap ? { srcMap } : NOTHING,
|
|
383
413
|
fontFamily,
|
|
384
414
|
fontSize,
|
|
385
|
-
...sizeMap ? { sizeMap } : NOTHING,
|
|
386
415
|
fontWeight,
|
|
387
416
|
fontStyle,
|
|
388
|
-
fill
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
417
|
+
fill,
|
|
418
|
+
letterSpacing,
|
|
419
|
+
underline,
|
|
420
|
+
strikethrough,
|
|
421
|
+
overline,
|
|
422
|
+
baselineShift: shiftEm * style.fontSize
|
|
423
|
+
};
|
|
424
|
+
if (srcMap) r.srcMap = srcMap;
|
|
425
|
+
if (sizeMap) r.sizeMap = sizeMap;
|
|
426
|
+
if (stroke !== void 0) r.stroke = stroke;
|
|
427
|
+
if (relative) r.strutSize = style.fontSize;
|
|
428
|
+
if (rotate !== void 0) r.rotate = rotate;
|
|
429
|
+
if (fontFeatures) r.fontFeatures = fontFeatures;
|
|
430
|
+
if (lang) r.lang = lang;
|
|
431
|
+
out[i] = r;
|
|
403
432
|
}
|
|
404
433
|
return out;
|
|
405
434
|
}
|
|
@@ -1111,7 +1140,7 @@ function assertOutlinable(run, caller) {
|
|
|
1111
1140
|
void loadFontOutlines(fontFamily, { weight: fontWeight, style: fontStyle });
|
|
1112
1141
|
fail("outlines-loading", "its outlines have not loaded yet; await loadTextOutlines first.");
|
|
1113
1142
|
}
|
|
1114
|
-
const r =
|
|
1143
|
+
const r = cachedFontVariant(fontFamily, fontWeight, fontStyle);
|
|
1115
1144
|
const { family, weight, style } = r.resolved;
|
|
1116
1145
|
if (r.source === "outline") return;
|
|
1117
1146
|
const status = outlineStatus(family, weight, style);
|
|
@@ -1201,7 +1230,7 @@ function facesOf(runs) {
|
|
|
1201
1230
|
};
|
|
1202
1231
|
for (const r of runs) {
|
|
1203
1232
|
add(r.fontFamily, r.fontWeight, r.fontStyle);
|
|
1204
|
-
const { family, weight, style } =
|
|
1233
|
+
const { family, weight, style } = cachedFontVariant(r.fontFamily, r.fontWeight, r.fontStyle).resolved;
|
|
1205
1234
|
add(family, weight, style);
|
|
1206
1235
|
}
|
|
1207
1236
|
return [...out.values()];
|
|
@@ -1359,6 +1388,6 @@ function clustersOf(data, width, scale) {
|
|
|
1359
1388
|
});
|
|
1360
1389
|
}
|
|
1361
1390
|
|
|
1362
|
-
export { MARKDOWN_RUN_GRAMMAR, SCRIPT_METRICS, SMALL_CAPS_SCALE, SYNTHETIC_ITALIC_RADIANS, TextOutlinesError, applyStyleToRange, caretIndexAt, createMarkdownRenderer, defaultLabelTextRenderer, effectiveRangeStyle, fitTextPose, glyphOutlineAt, glyphTurn, halfLeadingFor, isBoldWeight, isSmallCapsLetter, isTextData, layoutMarkdown, layoutTextPose, loadTextOutlines, markdownToRuns, measureText, measureTextBounds, measuredWidth, nodeHasFlag, numericWeight, patchRangeStyle, pointInTextPose, rangeWeight, renderLabel, resolveRunFace, resolveRuns, runsCarryStyling, runsToMarkdown, runsToPlainText, scriptMetrics, scriptMetricsFor, setFlagOverRange, smallCapsScale, smallCapsScaleFor, smallCapsText, styleAtRange, supersededKey, textClusters, textLineBoxes, textPoseLayoutInput, textToPath, textToPathsByPaint, toRuns, transformRunTexts, unboldPatch, verticalAlignOffset };
|
|
1391
|
+
export { MARKDOWN_RUN_GRAMMAR, SCRIPT_METRICS, SMALL_CAPS_SCALE, SYNTHETIC_ITALIC_RADIANS, TextOutlinesError, applyStyleToRange, caretIndexAt, createMarkdownRenderer, defaultLabelTextRenderer, effectiveRangeStyle, fitTextPose, glyphOutlineAt, glyphTurn, halfLeadingFor, isBoldWeight, isSmallCapsLetter, isTextData, layoutMarkdown, layoutTextPose, loadTextOutlines, markdownToRuns, measureText, measureTextBounds, measuredWidth, nodeHasFlag, numericWeight, patchRangeStyle, pointInTextPose, rangeWeight, renderLabel, resolveRunFace, resolveRuns, resolveRunsInto, runsCarryStyling, runsToMarkdown, runsToPlainText, scriptMetrics, scriptMetricsFor, setFlagOverRange, smallCapsScale, smallCapsScaleFor, smallCapsText, styleAtRange, supersededKey, textClusters, textLineBoxes, textPoseLayoutInput, textToPath, textToPathsByPaint, toRuns, transformRunTexts, unboldPatch, verticalAlignOffset };
|
|
1363
1392
|
//# sourceMappingURL=index.js.map
|
|
1364
1393
|
//# sourceMappingURL=index.js.map
|