vizmatic 0.5.0 → 0.6.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/PROMPT.md CHANGED
@@ -64,7 +64,7 @@ npx vizmatic film intro.ts --frame 3,6.5,12 --width 1280 --out stills
64
64
  npx vizmatic film intro.ts --out dist/films --look midnight,paper --quality high
65
65
  ```
66
66
 
67
- `vizmatic check` samples the moments where the film comes to rest. It reports `film.off_canvas`, `film.text_overlap`, and `film.text_crossed`, each with times, a `box` in canvas pixels, and a `stage` center in authoring coordinates. Fix every error, then open the stills and look at them. `vizmatic preview intro.ts` opens a live player with a timeline for a person to review.
67
+ `vizmatic check` samples the moments where the film comes to rest. It reports `film.off_canvas`, `film.text_overlap`, `film.text_crossed`, and `film.missing_glyph`, each with times, a `box` in canvas pixels, and a `stage` center in authoring coordinates. Fix every error, then open the stills and look at them. `vizmatic preview intro.ts` opens a live player with a timeline for a person to review.
68
68
 
69
69
  Motion guidance:
70
70
 
package/README.md CHANGED
@@ -120,7 +120,7 @@ Agents can also read [`llms.txt`](https://bvolpato.github.io/vizmatic/llms.txt),
120
120
 
121
121
  ## Consumer security overrides
122
122
 
123
- Vizmatic 0.5.0's MathJax tree resolves `speech-rule-engine`, which uses `@xmldom/xmldom`. Its Satori tree resolves `fflate`. Pin these patched transitive versions in a consuming project before you install Vizmatic.
123
+ Vizmatic 0.6.0's MathJax tree resolves `speech-rule-engine`, which uses `@xmldom/xmldom`. Its Satori tree resolves `fflate`. Pin these patched transitive versions in a consuming project before you install Vizmatic.
124
124
 
125
125
  For npm, add these root-level entries to `package.json`:
126
126
 
@@ -50,6 +50,10 @@ each under the MIT License. Their full notices are in
50
50
  - Instrument Serif: SIL Open Font License 1.1.
51
51
  Copyright 2022 The Instrument Serif Project Authors.
52
52
  Source: https://github.com/Instrument/instrument-serif
53
+ - Source Serif 4: SIL Open Font License 1.1.
54
+ Copyright 2014 The Source Serif 4 Project Authors.
55
+ Source: https://github.com/adobe-fonts/source-serif
56
+ `SourceSerif4-24pt-Regular.ttf` and `SourceSerif4-24pt-Italic.ttf` are static cuts of the variable fonts at optical size 24. `scripts/build-stage-fonts.py` makes them.
53
57
  - Noto Sans: SIL Open Font License 1.1.
54
58
  Copyright Google Inc.
55
59
  Source: https://github.com/notofonts/noto-fonts
@@ -2481,7 +2481,7 @@ function ghost(stage, from, to2, ctx) {
2481
2481
  node.tween("strokeOpacity", to2.strokeOpacity, ctx.t0, ctx.t1, ctx.ease);
2482
2482
  node.tween("strokeWidth", to2.strokeWidth || from.strokeWidth, ctx.t0, ctx.t1, ctx.ease);
2483
2483
  if (from.glow !== to2.glow) node.tween("glow", to2.glow, ctx.t0, ctx.t1, ctx.ease);
2484
- stepAt(node, "visible", false, ctx.t1);
2484
+ stepAt(node, "visible", false, ctx.hide ?? ctx.t1);
2485
2485
  return node;
2486
2486
  }
2487
2487
  function pairCounts(from, to2) {
@@ -2515,7 +2515,7 @@ function morph(from, to2, options = {}) {
2515
2515
  const each = (ctx.t1 - ctx.t0) / (1 + Math.max(0, pairs.length - 1) * lag);
2516
2516
  pairs.forEach(([x, y], i) => {
2517
2517
  const start = ctx.t0 + i * lag * each;
2518
- ghost(ctx.stage, x, y, { t0: start, t1: start + each, ease: ctx.ease, appear: ctx.t0 });
2518
+ ghost(ctx.stage, x, y, { t0: start, t1: start + each, ease: ctx.ease, appear: ctx.t0, hide: ctx.t1 });
2519
2519
  });
2520
2520
  finishMorph(a, b, ctx);
2521
2521
  }
@@ -3517,8 +3517,17 @@ function readPairs(r, sub) {
3517
3517
  var FILES = {
3518
3518
  sans: { "400": "Inter-Regular.ttf", "600": "Inter-SemiBold.ttf", "700": "Inter-Bold.ttf" },
3519
3519
  serif: { "400": "InstrumentSerif-Regular.ttf", "italic": "InstrumentSerif-Italic.ttf" },
3520
+ "text-serif": { "400": "SourceSerif4-24pt-Regular.ttf", "italic": "SourceSerif4-24pt-Italic.ttf" },
3520
3521
  mono: { "400": "JetBrainsMono-Regular.ttf" },
3521
- noto: { "400": "NotoSans-Regular.ttf" }
3522
+ noto: { "400": "NotoSans-Regular.ttf" },
3523
+ math: { "400": "NotoSansMath-Regular.ttf" }
3524
+ };
3525
+ var FALLBACKS = {
3526
+ sans: ["noto", "math"],
3527
+ serif: ["text-serif", "noto", "math"],
3528
+ "text-serif": ["noto", "math"],
3529
+ mono: ["noto", "math"],
3530
+ noto: ["math"]
3522
3531
  };
3523
3532
  var fonts = /* @__PURE__ */ new Map();
3524
3533
  var pending = /* @__PURE__ */ new Map();
@@ -3537,6 +3546,14 @@ function fontFor(family, weight = 400, italic = false) {
3537
3546
  }
3538
3547
  throw new Suspend(waiting);
3539
3548
  }
3549
+ function fallbackGlyph(family, code, weight = 400, italic = false) {
3550
+ for (const next of FALLBACKS[family]) {
3551
+ const font = fontFor(next, weight, italic);
3552
+ const glyph = font.glyphFor(code);
3553
+ if (glyph !== 0) return { font, glyph };
3554
+ }
3555
+ return null;
3556
+ }
3540
3557
  var glyphPaths = /* @__PURE__ */ new WeakMap();
3541
3558
  function glyphPath(font, glyph, size) {
3542
3559
  let bySize = glyphPaths.get(font);
@@ -3582,7 +3599,10 @@ function centered(path) {
3582
3599
  }
3583
3600
  function text(content, options = {}) {
3584
3601
  const size = options.size ?? 40;
3585
- const font = fontFor(options.font ?? "sans", options.weight ?? 400, options.italic ?? false);
3602
+ const family = options.font ?? "sans";
3603
+ const weight = options.weight ?? 400;
3604
+ const italic = options.italic ?? false;
3605
+ const font = fontFor(family, weight, italic);
3586
3606
  const scale = size / font.unitsPerEm;
3587
3607
  const tracking = (options.tracking ?? 0) * size;
3588
3608
  const leading = (options.leading ?? 1.3) * size;
@@ -3590,14 +3610,23 @@ function text(content, options = {}) {
3590
3610
  const source = options.uppercase ? content.toUpperCase() : content;
3591
3611
  const measureWord = (word) => {
3592
3612
  const glyphs = [];
3593
- let x = 0, previous = 0;
3613
+ let x = 0, previous = 0, previousFont = null;
3594
3614
  for (const char of word) {
3595
3615
  const code = char.codePointAt(0);
3596
- const glyph = font.glyphFor(code);
3597
- if (previous) x += font.kern(previous, glyph) * scale;
3598
- glyphs.push({ code, glyph, x, char });
3599
- x += font.advance(glyph) * scale + tracking;
3616
+ let owner = font, glyph = font.glyphFor(code);
3617
+ if (glyph === 0) {
3618
+ const found = fallbackGlyph(family, code, weight, italic);
3619
+ if (found) {
3620
+ owner = found.font;
3621
+ glyph = found.glyph;
3622
+ }
3623
+ }
3624
+ const ownerScale = size / owner.unitsPerEm;
3625
+ if (previous && previousFont === owner) x += owner.kern(previous, glyph) * ownerScale;
3626
+ glyphs.push({ font: owner, glyph, x, char });
3627
+ x += owner.advance(glyph) * ownerScale + tracking;
3600
3628
  previous = glyph;
3629
+ previousFont = owner;
3601
3630
  }
3602
3631
  return { glyphs, width: x };
3603
3632
  };
@@ -3627,13 +3656,14 @@ function text(content, options = {}) {
3627
3656
  lines.forEach((line, row) => {
3628
3657
  const start = align === "left" ? 0 : align === "center" ? (blockWidth - line.width) / 2 : blockWidth - line.width;
3629
3658
  for (const placed of line.glyphs) {
3630
- const path = glyphPath(font, placed.glyph, size);
3659
+ const path = glyphPath(placed.font, placed.glyph, size);
3631
3660
  if (path.length === 0) continue;
3632
3661
  const shape = centered(path);
3633
3662
  const leaf = new Node(shape.path).at(start + placed.x + shape.x, row * leading + shape.y);
3634
3663
  leaf.base.fill = paint;
3635
3664
  leaf.base.trimEach = true;
3636
3665
  leaf.data["key"] = placed.char;
3666
+ if (placed.glyph === 0) leaf.data["missingGlyph"] = true;
3637
3667
  node.chars.push(leaf);
3638
3668
  node.children.push(leaf);
3639
3669
  leaf.parent = node;