@weasel-js/text 1.14.1 → 1.14.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/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-DHGfE_6p.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 dropRuns, E as fontString, G as halfLeadingFor, H as isBoldWeight, I as isSmallCapsLetter, J as layoutRuns, K as markdownToRuns, N as numericWeight, O as paragraphDirection, Q as registerBidi, U as resolveAlign, V as resolveRunFace, W as resolveRuns, X as resolveTextStyle, Y as runsToMarkdown, Z as runsToPlainText, _ as scriptMetrics, $ as scriptMetricsFor, a0 as smallCapsScale, a1 as smallCapsScaleFor, a2 as smallCapsText, a3 as toRuns, a4 as transformRunTexts } from './test-seams-DHGfE_6p.js';
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-D6uEFbAw.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 dropRuns, E as fontString, G as halfLeadingFor, H as isBoldWeight, I as isSmallCapsLetter, J as layoutRuns, K as markdownToRuns, N as numericWeight, O as paragraphDirection, Q as registerBidi, U as resolveAlign, V as resolveRunFace, W as resolveRuns, X as resolveTextStyle, Y as resolveTextStyleInto, Z as runsToMarkdown, _ as runsToPlainText, $ as scriptMetrics, a0 as scriptMetricsFor, a1 as smallCapsScale, a2 as smallCapsScaleFor, a3 as smallCapsText, a4 as toRuns, a5 as transformRunTexts } from './test-seams-D6uEFbAw.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,5 +1,5 @@
1
- import { DEFAULT_TAB_SIZE, shapesWithFeature, resolveTextStyle, cachedLayoutRuns, graphemeCount, wrapLines, hangs, emboldenGlyph, layoutRuns, lineDecorations, runFaces, tabAdvance, widthWithTabs, DECORATION_KINDS, decorationRule, faceOutlineD, hasGlyphQuad } from './chunk-FODNMBHI.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, decorationMetrics, dropRuns, emboldenGlyphD, fontString, isHardLineBreak, layoutRuns, lineBreakOpportunities, paintRuns, paragraphDirection, registerBidi, registerShaper, resolveAlign, resolveTextStyle, syntheticBoldOffset } from './chunk-FODNMBHI.js';
1
+ import { DEFAULT_TAB_SIZE, shapesWithFeature, resolveTextStyle, cachedLayoutRuns, graphemeCount, wrapLines, hangs, emboldenGlyph, layoutRuns, lineDecorations, runFaces, tabAdvance, widthWithTabs, DECORATION_KINDS, decorationRule, faceOutlineD, hasGlyphQuad } from './chunk-5BJN6MC6.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, decorationMetrics, dropRuns, emboldenGlyphD, fontString, isHardLineBreak, layoutRuns, lineBreakOpportunities, paintRuns, paragraphDirection, registerBidi, registerShaper, resolveAlign, resolveTextStyle, resolveTextStyleInto, syntheticBoldOffset } from './chunk-5BJN6MC6.js';
3
3
  import { resolveScreenLength, paintKey, strokeKey } from '@weasel-js/paint';
4
4
  import { faceMetricsOf, resolveFontVariant, loadFontOutlines, glyphGeneration, faceMetricsFor, outlineStatus, cssFamilyName } from '@weasel-js/font';
5
5
  import { MIXED, deepEqual } from '@weasel-js/registry';
@@ -341,9 +341,8 @@ 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
- const out = [];
345
+ const out = new Array(runs.length);
347
346
  let transformed = false;
348
347
  for (const r of runs) if ((r.textTransform ?? style.textTransform) !== "none") transformed = true;
349
348
  const shown = transformed ? transformRunTexts(
@@ -377,29 +376,29 @@ function resolveRuns(runs, style, viewScale = 1) {
377
376
  }
378
377
  }
379
378
  const lang = run.lang ?? style.lang;
380
- out.push({
379
+ const r = {
381
380
  text,
382
- ...srcMap ? { srcMap } : NOTHING,
383
381
  fontFamily,
384
382
  fontSize,
385
- ...sizeMap ? { sizeMap } : NOTHING,
386
383
  fontWeight,
387
384
  fontStyle,
388
385
  fill: run.fill !== void 0 ? run.fill : style.fill,
389
- // Unlike the decorations below, a run's stroke *replaces* the node's
390
- // rather than adding to it — there is only one outline to paint.
391
- ...(run.stroke ?? style.stroke) !== void 0 ? { stroke: run.stroke ?? style.stroke } : NOTHING,
392
386
  letterSpacing: run.letterSpacing !== void 0 ? resolveScreenLength(run.letterSpacing, viewScale) : style.letterSpacing,
393
387
  // `||`, not `??`: run-level decorations are additive over the node style.
394
388
  underline: run.underline || style.underline,
395
389
  strikethrough: run.strikethrough || style.strikethrough,
396
390
  overline: run.overline || style.overline,
397
- baselineShift: shiftEm * style.fontSize,
398
- ...relative ? { strutSize: style.fontSize } : NOTHING,
399
- ...run.rotate && Number.isFinite(run.rotate) ? { rotate: run.rotate } : NOTHING,
400
- ...fontFeatures ? { fontFeatures } : NOTHING,
401
- ...lang ? { lang } : NOTHING
402
- });
391
+ baselineShift: shiftEm * style.fontSize
392
+ };
393
+ if (srcMap) r.srcMap = srcMap;
394
+ if (sizeMap) r.sizeMap = sizeMap;
395
+ const stroke = run.stroke ?? style.stroke;
396
+ if (stroke !== void 0) r.stroke = stroke;
397
+ if (relative) r.strutSize = style.fontSize;
398
+ if (run.rotate && Number.isFinite(run.rotate)) r.rotate = run.rotate;
399
+ if (fontFeatures) r.fontFeatures = fontFeatures;
400
+ if (lang) r.lang = lang;
401
+ out[i] = r;
403
402
  }
404
403
  return out;
405
404
  }