@weasel-js/text 1.14.2 → 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-5BJN6MC6.js → chunk-ZNSU5C43.js} +54 -18
- package/dist/chunk-ZNSU5C43.js.map +1 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +48 -18
- package/dist/index.js.map +1 -1
- package/dist/{test-seams-D6uEFbAw.d.ts → test-seams-Ck0mfD3U.d.ts} +28 -1
- package/dist/test-seams.d.ts +1 -1
- package/dist/test-seams.js +1 -1
- package/package.json +6 -6
- package/dist/chunk-5BJN6MC6.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, resolveTextStyleInto, 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
|
}
|
|
@@ -342,7 +342,10 @@ function resolveRunFace(run, style) {
|
|
|
342
342
|
};
|
|
343
343
|
}
|
|
344
344
|
function resolveRuns(runs, style, viewScale = 1) {
|
|
345
|
-
|
|
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;
|
|
346
349
|
let transformed = false;
|
|
347
350
|
for (const r of runs) if ((r.textTransform ?? style.textTransform) !== "none") transformed = true;
|
|
348
351
|
const shown = transformed ? transformRunTexts(
|
|
@@ -376,26 +379,53 @@ function resolveRuns(runs, style, viewScale = 1) {
|
|
|
376
379
|
}
|
|
377
380
|
}
|
|
378
381
|
const lang = run.lang ?? style.lang;
|
|
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
|
+
}
|
|
379
411
|
const r = {
|
|
380
412
|
text,
|
|
381
413
|
fontFamily,
|
|
382
414
|
fontSize,
|
|
383
415
|
fontWeight,
|
|
384
416
|
fontStyle,
|
|
385
|
-
fill
|
|
386
|
-
letterSpacing
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
overline: run.overline || style.overline,
|
|
417
|
+
fill,
|
|
418
|
+
letterSpacing,
|
|
419
|
+
underline,
|
|
420
|
+
strikethrough,
|
|
421
|
+
overline,
|
|
391
422
|
baselineShift: shiftEm * style.fontSize
|
|
392
423
|
};
|
|
393
424
|
if (srcMap) r.srcMap = srcMap;
|
|
394
425
|
if (sizeMap) r.sizeMap = sizeMap;
|
|
395
|
-
const stroke = run.stroke ?? style.stroke;
|
|
396
426
|
if (stroke !== void 0) r.stroke = stroke;
|
|
397
427
|
if (relative) r.strutSize = style.fontSize;
|
|
398
|
-
if (
|
|
428
|
+
if (rotate !== void 0) r.rotate = rotate;
|
|
399
429
|
if (fontFeatures) r.fontFeatures = fontFeatures;
|
|
400
430
|
if (lang) r.lang = lang;
|
|
401
431
|
out[i] = r;
|
|
@@ -1110,7 +1140,7 @@ function assertOutlinable(run, caller) {
|
|
|
1110
1140
|
void loadFontOutlines(fontFamily, { weight: fontWeight, style: fontStyle });
|
|
1111
1141
|
fail("outlines-loading", "its outlines have not loaded yet; await loadTextOutlines first.");
|
|
1112
1142
|
}
|
|
1113
|
-
const r =
|
|
1143
|
+
const r = cachedFontVariant(fontFamily, fontWeight, fontStyle);
|
|
1114
1144
|
const { family, weight, style } = r.resolved;
|
|
1115
1145
|
if (r.source === "outline") return;
|
|
1116
1146
|
const status = outlineStatus(family, weight, style);
|
|
@@ -1200,7 +1230,7 @@ function facesOf(runs) {
|
|
|
1200
1230
|
};
|
|
1201
1231
|
for (const r of runs) {
|
|
1202
1232
|
add(r.fontFamily, r.fontWeight, r.fontStyle);
|
|
1203
|
-
const { family, weight, style } =
|
|
1233
|
+
const { family, weight, style } = cachedFontVariant(r.fontFamily, r.fontWeight, r.fontStyle).resolved;
|
|
1204
1234
|
add(family, weight, style);
|
|
1205
1235
|
}
|
|
1206
1236
|
return [...out.values()];
|
|
@@ -1358,6 +1388,6 @@ function clustersOf(data, width, scale) {
|
|
|
1358
1388
|
});
|
|
1359
1389
|
}
|
|
1360
1390
|
|
|
1361
|
-
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 };
|
|
1362
1392
|
//# sourceMappingURL=index.js.map
|
|
1363
1393
|
//# sourceMappingURL=index.js.map
|