Clone any viral video with AI agents. Not just a script, the whole workflow: swap the face, the words, the B-roll, ship 100 variants in one command, and get your 100M views.
TypeScript agentic-aiaiai-agentsai-videocompilerdslffmpeggenerative-aillmmarkup-languagemonorepoplugin-systemprogramming-languagetext-to-videotypescriptvideovideo-automationvideo-clonevideo-editingvideo-generation
feat: finish fine caption evidence
kashorin71924dfcc1f7
diff --git a/docs/quickstart/styles.md b/docs/quickstart/styles.mdindex 587c0d9e..02173b60 100644--- a/docs/quickstart/styles.md+++ b/docs/quickstart/styles.md@@ -319,6 +319,8 @@ the author source with the independently imported Media package:weight="600" style="normal"/><media:Font id="inter-black" src="./assets/Inter-Black.woff2"weight="900" style="normal"/>+<media:Font id="noto-cjk-semibold" src="./assets/NotoSansCJK-SemiBold.otf"+ weight="600" style="normal"/>```| Property | Description |@@ -332,11 +334,15 @@ component chooses it with a normal source reference; the Runtime never guesses a```svml<caption-fine:Style id="dialogue" recipe={studio.caption.dialogue}- font={inter-semibold}/>+ font={inter-semibold}>+ <caption-fine:Fallback font={noto-cjk-semibold}/>+</caption-fine:Style>```-Omitting `font=` keeps the Recipe's `font` family as an environment fallback, which is convenient-for prototypes but is not byte-reproducible.+`font=` is the primary face; ordered `Fallback` children cover additional glyph sets such as CJK or+emoji. Every face must match the Recipe's weight/style. Omitting the stack keeps the Recipe's+`font` family as an environment fallback, which is convenient for prototypes but is not+byte-reproducible.## Combination examplediff --git a/docs/quickstart/tracks.md b/docs/quickstart/tracks.mdindex 6bc93748..fd31e1b4 100644--- a/docs/quickstart/tracks.md+++ b/docs/quickstart/tracks.md@@ -59,13 +59,18 @@ caption.primary {```svml<media:Font id="caption-font" src="./assets/Inter-Bold.woff2"weight="700" style="normal"/>+<media:Font id="caption-cjk" src="./assets/NotoSansCJK-Bold.otf"+ weight="700" style="normal"/><caption-fine:Style id="primary-caption" recipe={studio.caption.primary}- font={caption-font}/>+ font={caption-font}>+ <caption-fine:Fallback font={caption-cjk}/>+</caption-fine:Style>```-The explicit `font=` edge makes the rendered face byte-reproducible. Omitting it deliberately uses-the Recipe's `font` family as an environment fallback; neither Caption nor the Runtime chooses a-font on the author's behalf.+The explicit `font=` edge and ordered `Fallback` children make the rendered stack+byte-reproducible. Every face must match the Recipe's weight/style. Omitting the stack deliberately+uses the Recipe's `font` family as an environment fallback; neither Caption nor the Runtime chooses+a font on the author's behalf.Another Caption package may define completely different planning fields and visual parameterswithout changing the common package.@@ -80,6 +85,13 @@ decoration or motion. Unknown properties are rejected.whole-Atom timing already proven by Caption. A normal one-word Atom therefore highlights per word,while a Dual Text Atom remains one indivisible visible unit. Fine never guesses internal time.+Fine wraps only between complete Atoms and never clips author text. It intentionally has no+`max-lines`; use Cue bounds, Track width and font size to control density.++CJK dialogue can be written directly. For a display-only emoji that still follows speech timing,+author the correspondence explicitly, such as `<🌐 | globe>`; the system will not invent a spoken+word for a bare symbol.+### caption:ProgramThe Program starts from the complete ordered display-word universe emitted by Script. One explicitdiff --git a/docs/zh/quickstart/styles.md b/docs/zh/quickstart/styles.mdindex a1995cbb..a49ea57c 100644--- a/docs/zh/quickstart/styles.md+++ b/docs/zh/quickstart/styles.md@@ -314,6 +314,8 @@ SVS 描述字体策略,但不负责打开文件。具体字体文件由独立weight="600" style="normal"/><media:Font id="inter-black" src="./assets/Inter-Black.woff2"weight="900" style="normal"/>+<media:Font id="noto-cjk-semibold" src="./assets/NotoSansCJK-SemiBold.otf"+ weight="600" style="normal"/>```| 属性 | 描述 |@@ -327,10 +329,14 @@ Runtime 不猜字体:```svml<caption-fine:Style id="dialogue" recipe={studio.caption.dialogue}- font={inter-semibold}/>+ font={inter-semibold}>+ <caption-fine:Fallback font={noto-cjk-semibold}/>+</caption-fine:Style>```-省略 `font=` 时会使用 Recipe 的环境字体兜底名,适合原型,但不能保证字节级复现。+`font=` 是主字体,有序 `Fallback` 子元素用于覆盖 CJK、emoji 等额外字形集合。所有字体+都必须和 Recipe 的 weight/style 一致。省略字体栈时会使用 Recipe 的环境字体兜底名,+适合原型,但不能保证字节级复现。## 综合示例diff --git a/docs/zh/quickstart/tracks.md b/docs/zh/quickstart/tracks.mdindex 9e210c94..8627aa7e 100644--- a/docs/zh/quickstart/tracks.md+++ b/docs/zh/quickstart/tracks.md@@ -33,16 +33,27 @@ Script 显示全集 → Caption Program → Planner + Atom 实测时间 → 样```svml<media:Font id="caption-font" src="./assets/Inter-Bold.woff2"weight="700" style="normal"/>+<media:Font id="caption-cjk" src="./assets/NotoSansCJK-Bold.otf"+ weight="700" style="normal"/><caption-fine:Style id="primary-caption" recipe={studio.caption.primary}- font={caption-font}/>+ font={caption-font}>+ <caption-fine:Fallback font={caption-cjk}/>+</caption-fine:Style>```-显式的 `font=` 边让最终字体按字节复现。省略它则明确使用 Recipe 的环境字体兜底名;-Caption 和 Runtime 都不会替作者猜字体。+显式的 `font=` 边与有序 `Fallback` 子元素让最终字体栈按字节复现。每个字体都必须与+Recipe 的 weight/style 一致。省略字体栈则明确使用 Recipe 的环境字体兜底名;Caption+和 Runtime 都不会替作者猜字体。Recipe 同时包含 `cue-min-words`、`cue-max-words` 和完整字体/框参数。Fine 不声明任何逐词字段;其他字幕包可以定义完全不同的字段和渲染方式,无需修改公共 Caption。+Fine 只在完整 Atom 之间自然换行,永不裁掉作者文字,因此有意不提供 `max-lines`。+需要控制行数时,应调整 Cue 字数边界、Track 宽度与字号。++CJK 口播可以直接书写。若一个只负责显示的 emoji 仍需跟随语音计时,应显式写出对应,+例如 `<🌐 | globe>`;系统不会替裸符号虚构一个口播词。+### caption:ProgramProgram 消费 Script 显式输出的完整有序显示词全集。一个必填的默认 Style 自动覆盖diff --git a/examples/talking-film-graph-check/svml.packages.lock b/examples/talking-film-graph-check/svml.packages.lockindex 87812392..ddd203a3 100644--- a/examples/talking-film-graph-check/svml.packages.lock+++ b/examples/talking-film-graph-check/svml.packages.lock@@ -14,7 +14,7 @@{"name": "@narratage/caption-fine","version": "0.0.0-dev",- "digest": "sha256:5e13972ce06fd1b210f983f78d773bf88512995145e1356c1962d8b7d9fee944"+ "digest": "sha256:09c130ab2c5dec518123fef62aec3523969dd8921309115219ed2683010c5aa7"},{"name": "@narratage/caption-gemini",@@ -69,7 +69,7 @@{"name": "@narratage/hyperframes","version": "0.0.0-dev",- "digest": "sha256:fc1c5605c166c53e2d378cf5cfac7f8dc6ba20a40fcfdcd89a96e8447577d9bf"+ "digest": "sha256:797eacc6e725ea42b989ed50d06640471307da4e2d6fa132491cfb9d7c26120d"},{"name": "@narratage/media-pipeline",@@ -226,8 +226,8 @@"name": "@narratage/caption-fine","version": "0.0.0-dev"},- "facetsDigest": "sha256:7c1efe270d1d063fbdfb2ee652ca568860b09b007ced8d01068ff8052175d320",- "closureDigest": "sha256:6ef02ec445f09476d1ebb6d25acb1b6eccdb27eb76727a450f990273e8ec1182"+ "facetsDigest": "sha256:f6a9db8a527a3ffee84d2c605907b45a57803832b33e33d046fdca71357ccb2b",+ "closureDigest": "sha256:2e9e72556c188beff234a5fab1482e44d4f40d5c1ca898ece471cc47dd584465"},{"specifier": "@narratage/caption-gemini",@@ -281,7 +281,7 @@"version": "0.0.0-dev"},"facetsDigest": "sha256:8a18bd638a89adcd7e3865db23f82f6b56ffe79353cb7c71ef906d3485559a28",- "closureDigest": "sha256:0d9b05c526fa0a6c2cb8ab1542e0de9b601187a3101dc23d784ea1bc20a5eb96"+ "closureDigest": "sha256:04629d4293b3e08e6dcc9b5b1f4855eb3ada71f845c7e9c9c80097700496fa95"},{"specifier": "@narratage/media",@@ -326,7 +326,7 @@"version": "0.0.0-dev"},"facetsDigest": "sha256:dd7a1214338a4622e92dba3ff8b9368609905f99d36f8f178be7e29a2e8022d8",- "closureDigest": "sha256:b50c56f978353cba701f31434c567ce9f1b4421d82c1f4533c3245f3d4c52815"+ "closureDigest": "sha256:ebdf8a27b1da120efa9f1b5e545dac1f6f9e56bdb8125f7e7dfd131b798868d7"},{"specifier": "@narratage/run-text",@@ -446,5 +446,5 @@"closureDigest": "sha256:4e3758c963992904ed7997e3dfcad69f8c6547d8a36ca52ffd62ac2bb913530b"}],- "digest": "sha256:3c5b0371cd2f7a143bba634f8739c3b4978f48c81ac8697349899642a6d456d4"+ "digest": "sha256:be77fae63251971d3c91cef666f22c55574f158b81962f502acdf7031d7e23cf"}diff --git a/examples/talking-film-live/svml.packages.lock b/examples/talking-film-live/svml.packages.lockindex fa8bbc34..3452b0cc 100644--- a/examples/talking-film-live/svml.packages.lock+++ b/examples/talking-film-live/svml.packages.lock@@ -9,7 +9,7 @@{"name": "@narratage/caption-fine","version": "0.0.0-dev",- "digest": "sha256:5e13972ce06fd1b210f983f78d773bf88512995145e1356c1962d8b7d9fee944"+ "digest": "sha256:09c130ab2c5dec518123fef62aec3523969dd8921309115219ed2683010c5aa7"},{"name": "@narratage/caption-gemini",@@ -64,7 +64,7 @@{"name": "@narratage/hyperframes","version": "0.0.0-dev",- "digest": "sha256:fc1c5605c166c53e2d378cf5cfac7f8dc6ba20a40fcfdcd89a96e8447577d9bf"+ "digest": "sha256:797eacc6e725ea42b989ed50d06640471307da4e2d6fa132491cfb9d7c26120d"},{"name": "@narratage/media-pipeline",@@ -212,8 +212,8 @@"name": "@narratage/caption-fine","version": "0.0.0-dev"},- "facetsDigest": "sha256:7c1efe270d1d063fbdfb2ee652ca568860b09b007ced8d01068ff8052175d320",- "closureDigest": "sha256:6ef02ec445f09476d1ebb6d25acb1b6eccdb27eb76727a450f990273e8ec1182"+ "facetsDigest": "sha256:f6a9db8a527a3ffee84d2c605907b45a57803832b33e33d046fdca71357ccb2b",+ "closureDigest": "sha256:2e9e72556c188beff234a5fab1482e44d4f40d5c1ca898ece471cc47dd584465"},{"specifier": "@narratage/caption-gemini",@@ -267,7 +267,7 @@"version": "0.0.0-dev"},"facetsDigest": "sha256:8a18bd638a89adcd7e3865db23f82f6b56ffe79353cb7c71ef906d3485559a28",- "closureDigest": "sha256:0d9b05c526fa0a6c2cb8ab1542e0de9b601187a3101dc23d784ea1bc20a5eb96"+ "closureDigest": "sha256:04629d4293b3e08e6dcc9b5b1f4855eb3ada71f845c7e9c9c80097700496fa95"},{"specifier": "@narratage/media",@@ -312,7 +312,7 @@"version": "0.0.0-dev"},"facetsDigest": "sha256:dd7a1214338a4622e92dba3ff8b9368609905f99d36f8f178be7e29a2e8022d8",- "closureDigest": "sha256:b50c56f978353cba701f31434c567ce9f1b4421d82c1f4533c3245f3d4c52815"+ "closureDigest": "sha256:ebdf8a27b1da120efa9f1b5e545dac1f6f9e56bdb8125f7e7dfd131b798868d7"},{"specifier": "@narratage/run-text",@@ -432,5 +432,5 @@"closureDigest": "sha256:4e3758c963992904ed7997e3dfcad69f8c6547d8a36ca52ffd62ac2bb913530b"}],- "digest": "sha256:61881034be53f952835f1d3d069f8393ac3350028d6e77cf26ad0faa2473ea31"+ "digest": "sha256:80a55c42c3f6c4edcff749fff6b67152b6beb849048e70b5d2728a18d760137b"}diff --git a/examples/talking-head-aroll/svml.packages.lock b/examples/talking-head-aroll/svml.packages.lockindex b6b2aa68..4eef32e7 100644--- a/examples/talking-head-aroll/svml.packages.lock+++ b/examples/talking-head-aroll/svml.packages.lock@@ -9,7 +9,7 @@{"name": "@narratage/caption-fine","version": "0.0.0-dev",- "digest": "sha256:5e13972ce06fd1b210f983f78d773bf88512995145e1356c1962d8b7d9fee944"+ "digest": "sha256:09c130ab2c5dec518123fef62aec3523969dd8921309115219ed2683010c5aa7"},{"name": "@narratage/caption-gemini",@@ -64,7 +64,7 @@{"name": "@narratage/hyperframes","version": "0.0.0-dev",- "digest": "sha256:fc1c5605c166c53e2d378cf5cfac7f8dc6ba20a40fcfdcd89a96e8447577d9bf"+ "digest": "sha256:797eacc6e725ea42b989ed50d06640471307da4e2d6fa132491cfb9d7c26120d"},{"name": "@narratage/media-pipeline",@@ -217,8 +217,8 @@"name": "@narratage/caption-fine","version": "0.0.0-dev"},- "facetsDigest": "sha256:7c1efe270d1d063fbdfb2ee652ca568860b09b007ced8d01068ff8052175d320",- "closureDigest": "sha256:6ef02ec445f09476d1ebb6d25acb1b6eccdb27eb76727a450f990273e8ec1182"+ "facetsDigest": "sha256:f6a9db8a527a3ffee84d2c605907b45a57803832b33e33d046fdca71357ccb2b",+ "closureDigest": "sha256:2e9e72556c188beff234a5fab1482e44d4f40d5c1ca898ece471cc47dd584465"},{"specifier": "@narratage/caption-gemini",@@ -272,7 +272,7 @@"version": "0.0.0-dev"},"facetsDigest": "sha256:8a18bd638a89adcd7e3865db23f82f6b56ffe79353cb7c71ef906d3485559a28",- "closureDigest": "sha256:0d9b05c526fa0a6c2cb8ab1542e0de9b601187a3101dc23d784ea1bc20a5eb96"+ "closureDigest": "sha256:04629d4293b3e08e6dcc9b5b1f4855eb3ada71f845c7e9c9c80097700496fa95"},{"specifier": "@narratage/media",@@ -326,7 +326,7 @@"version": "0.0.0-dev"},"facetsDigest": "sha256:dd7a1214338a4622e92dba3ff8b9368609905f99d36f8f178be7e29a2e8022d8",- "closureDigest": "sha256:b50c56f978353cba701f31434c567ce9f1b4421d82c1f4533c3245f3d4c52815"+ "closureDigest": "sha256:ebdf8a27b1da120efa9f1b5e545dac1f6f9e56bdb8125f7e7dfd131b798868d7"},{"specifier": "@narratage/run-text",@@ -446,5 +446,5 @@"closureDigest": "sha256:4e3758c963992904ed7997e3dfcad69f8c6547d8a36ca52ffd62ac2bb913530b"}],- "digest": "sha256:ea0ecf1eea16ea80dc8a88a900fb4206d723971a8c2a3c3b2d5b582c05f8e2c3"+ "digest": "sha256:278b87c91192a67ef6b166b9d98d6ea6db8c7f09cf3d7be5fb63f8ba9404dda6"}diff --git a/packages/caption-fine/README.md b/packages/caption-fine/README.mdindex d26275b4..98a2d20b 100644--- a/packages/caption-fine/README.md+++ b/packages/caption-fine/README.md@@ -10,7 +10,10 @@ no planning fields and has no `important`, random sizing or inferred Word timest```xml<media:Font id="caption-font" src="./Inter-SemiBold.woff2" weight="600" style="normal"/>-<fine:Style id="primary" recipe={studio.caption.primary} font={caption-font}/>+<media:Font id="caption-cjk" src="./NotoSansCJK-SemiBold.otf" weight="600" style="normal"/>+<fine:Style id="primary" recipe={studio.caption.primary} font={caption-font}>+ <fine:Fallback font={caption-cjk}/>+</fine:Style><caption:Program id="captions" display={story.caption} default={primary}/>@@ -25,8 +28,9 @@ no planning fields and has no `important`, random sizing or inferred Word timest/>```-One Track handles the default and ordered Style replacements. `font=` is optional for environment-font prototyping and explicit for reproducible builds; it references the existing Media-`FontArtifactRef` and must match the Recipe's weight/style. Common Caption, Composition and Core-know none of Fine's Recipe fields or layout policy. See `spec/caption-fine.md` for the full parameter-surface, defaults, non-goals and remaining visual evidence gates.+One Track handles the default and ordered Style replacements. `font=` plus ordered `Fallback`+children form an exact font stack for reproducible builds; all faces reference existing Media+`FontArtifactRef` values and must match the Recipe's weight/style. Omitting the stack is the explicit+environment-font prototype path. Fine never clips author text and intentionally has no `max-lines`.+Common Caption, Composition and Core know none of Fine's Recipe fields or layout policy. See+`spec/caption-fine.md` for the full parameter surface, defaults and non-goals.diff --git a/packages/caption-fine/src/manifest.ts b/packages/caption-fine/src/manifest.tsindex 5f2f63a5..9cdcf6bb 100644--- a/packages/caption-fine/src/manifest.ts+++ b/packages/caption-fine/src/manifest.ts@@ -13,7 +13,7 @@ export const captionFineModuleRef = { name: "@narratage/caption-fine", version:export const captionFineProducers = {render: { module: captionFineModuleRef, name: "render-fine-caption" },} satisfies Record<string, ProducerRef>;-export const captionFineStyleSurfaceImplementationDigest = digestOf("@narratage/caption-fine/exact-font-style-surface@1");+export const captionFineStyleSurfaceImplementationDigest = digestOf("@narratage/caption-fine/exact-font-stack-style-surface@1");export const captionFineTrackSurfaceImplementationDigest = digestOf("@narratage/caption-fine/whole-atom-track-surface@1");export const captionFineManifest: ModuleManifest = {diff --git a/packages/caption-fine/src/render.ts b/packages/caption-fine/src/render.tsindex deac2033..190bf783 100644--- a/packages/caption-fine/src/render.ts+++ b/packages/caption-fine/src/render.ts@@ -18,7 +18,7 @@ import { digestOf } from "@narratage/protocol";import { assertFineCaptionParameters, FINE_CAPTION_FAMILY } from "./style.js";import type { FineCaptionGlyphPaint, FineCaptionParameters } from "./types.js";-export const renderFineCaptionImplementationDigest = digestOf("@narratage/caption-fine/render-atom-paint-karaoke@1");+export const renderFineCaptionImplementationDigest = digestOf("@narratage/caption-fine/render-exact-font-stack@1");function frameAt(space: ProgramSpace, seconds: number): number {return Math.round(seconds * space.frameRate.numerator / space.frameRate.denominator);@@ -56,7 +56,7 @@ function glyphStyle(parameters: FineCaptionParameters, paint: FineCaptionGlyphPareturn [{ name: "color", value: paint.fill },{ name: "font-size", value: `${compactNumber(parameters.typography.fontSizePx)}px` },- ...(parameters.typography.exactFont === undefined ? [+ ...(parameters.typography.exactFonts === undefined ? [{ name: "font-family", value: parameters.typography.fontFamily },{ name: "font-style", value: parameters.typography.fontStyle },{ name: "font-weight", value: parameters.typography.fontWeight },@@ -255,7 +255,7 @@ function cueElements(kind: "text",text,style: glyphStyle(parameters, parameters.basePaint),- ...(parameters.typography.exactFont === undefined ? {} : { fonts: [parameters.typography.exactFont] }),+ ...(parameters.typography.exactFonts === undefined ? {} : { fonts: parameters.typography.exactFonts }),attributes: [{ name: "data-caption-word", value: wordId }],});}@@ -285,7 +285,7 @@ function cueElements(kind: "text",text,style: glyphStyle(parameters, parameters.activePaint),- ...(parameters.typography.exactFont === undefined ? {} : { fonts: [parameters.typography.exactFont] }),+ ...(parameters.typography.exactFonts === undefined ? {} : { fonts: parameters.typography.exactFonts }),attributes: [{ name: "data-caption-active-word", value: wordId }],});}diff --git a/packages/caption-fine/src/style.ts b/packages/caption-fine/src/style.tsindex 10430811..382c58f4 100644--- a/packages/caption-fine/src/style.ts+++ b/packages/caption-fine/src/style.ts@@ -132,7 +132,10 @@ function assertPaint(value: FineCaptionGlyphPaint, label: string): void {}}-export function fineCaptionParameters(recipe: SvsRecipe, exactFont?: FontArtifactRef): FineCaptionParameters {+export function fineCaptionParameters(+ recipe: SvsRecipe,+ exactFonts: readonly FontArtifactRef[] = [],+): FineCaptionParameters {for (const name of REQUIRED_PROPERTIES) required(recipe, name);const unknown = Object.keys(recipe.properties).filter((name) => !ALLOWED_PROPERTIES.has(name));if (unknown.length > 0) throw new Error(`Fine Caption Recipe contains unknown property ${unknown[0]}`);@@ -162,7 +165,7 @@ export function fineCaptionParameters(recipe: SvsRecipe, exactFont?: FontArtifacfontSizePx,fontWeight: integer(recipe, "weight"),fontStyle: choice(recipe, "font-style", ["normal", "italic", "oblique"] as const, "normal"),- ...(exactFont === undefined ? {} : { exactFont }),+ ...(exactFonts.length === 0 ? {} : { exactFonts: [...exactFonts] }),},basePaint,activePaint: glyphPaint(recipe, "active-", basePaint),@@ -210,11 +213,16 @@ export function assertFineCaptionParameters(value: FineCaptionParameters): voidif (!value.typography.fontFamily.trim() || value.typography.fontWeight < 1 || value.typography.fontWeight > 1000) {throw new Error("Fine Caption typography is invalid");}- if (value.typography.exactFont !== undefined) {- assertFontArtifactRef(value.typography.exactFont, "Fine Caption exact Font");- if (value.typography.exactFont.weight !== value.typography.fontWeight- || value.typography.exactFont.style !== value.typography.fontStyle) {- throw new Error("Fine Caption exact Font face must match Recipe weight and font-style");+ if (value.typography.exactFonts !== undefined) {+ if (value.typography.exactFonts.length === 0) throw new Error("Fine Caption exact Font stack is empty");+ const artifacts = new Set<string>();+ for (const [index, font] of value.typography.exactFonts.entries()) {+ assertFontArtifactRef(font, `Fine Caption exact Font ${index + 1}`);+ if (font.weight !== value.typography.fontWeight || font.style !== value.typography.fontStyle) {+ throw new Error("Fine Caption exact Font faces must match Recipe weight and font-style");+ }+ if (artifacts.has(font.artifact.digest)) throw new Error("Fine Caption exact Font stack contains a duplicate face");+ artifacts.add(font.artifact.digest);}}assertColor(value.cueBox.background, "Fine Caption background");@@ -223,7 +231,11 @@ export function assertFineCaptionParameters(value: FineCaptionParameters): voidassertPaint(value.activePaint, "Fine Caption active Paint");}-export function fineCaptionStyle(id: string, recipe: SvsRecipe, exactFont?: FontArtifactRef): CaptionStyleIntent {+export function fineCaptionStyle(+ id: string,+ recipe: SvsRecipe,+ exactFonts: readonly FontArtifactRef[] = [],+): CaptionStyleIntent {const minimumWords = integer(recipe, "cue-min-words");const maximumWords = integer(recipe, "cue-max-words");if (minimumWords <= 0 || maximumWords < minimumWords) {@@ -242,7 +254,7 @@ export function fineCaptionStyle(id: string, recipe: SvsRecipe, exactFont?: Font},rendering: {family: FINE_CAPTION_FAMILY,- parameters: fineCaptionParameters(recipe, exactFont),+ parameters: fineCaptionParameters(recipe, exactFonts),},});}diff --git a/packages/caption-fine/src/surface.ts b/packages/caption-fine/src/surface.tsindex 6901ccbc..e04c3d43 100644--- a/packages/caption-fine/src/surface.ts+++ b/packages/caption-fine/src/surface.ts@@ -56,22 +56,50 @@ function inline<T>(referenceValue: SurfaceResolvedReference, subject: string): Treturn referenceValue.record.value.value as unknown as T;}+function localName(name: string): string {+ const colon = name.lastIndexOf(":");+ return colon < 0 ? name : name.slice(colon + 1);+}++function exactFonts(+ element: StructuredElement,+ resolveReference: (path: string) => SurfaceResolvedReference | undefined,+): FontArtifactRef[] {+ const result: FontArtifactRef[] = [];+ const primary = element.attributes.font;+ if (primary !== undefined) {+ result.push(inline<FontArtifactRef>(+ reference(element, "font", mediaTypes.fontArtifact, resolveReference),+ `${element.name}.font`,+ ));+ }+ for (const child of element.children) {+ if (child.kind === "text") {+ if (child.value.trim()) throw new Error(`${element.name} accepts only Fallback children`);+ continue;+ }+ if (localName(child.name) !== "Fallback") throw new Error(`${element.name} accepts only Fallback children`);+ attributes(child, ["font"]);+ if (child.children.some((nested) => nested.kind === "element" || nested.value.trim())) {+ throw new Error(`${child.name} does not accept children`);+ }+ result.push(inline<FontArtifactRef>(+ reference(child, "font", mediaTypes.fontArtifact, resolveReference),+ `${child.name}.font`,+ ));+ }+ if (primary === undefined && result.length > 0) {+ throw new Error(`${element.name} requires font before Fallback children`);+ }+ for (const [index, font] of result.entries()) assertFontArtifactRef(font, `${element.name}.font.${index + 1}`);+ return result;+}+export const decodeFineCaptionStyleSurface: StructuredSurfaceHandler = ({ element, resolveReference }) => {attributes(element, ["id", "recipe"], ["font"]);- if (element.children.some((child) => child.kind === "element" || child.value.trim())) {- throw new Error(`${element.name} does not accept children`);- }const id = stringAttribute(element, "id");const recipe = inline<SvsRecipe>(reference(element, "recipe", svsRecipeType, resolveReference), `${element.name}.recipe`);- const fontAttribute = element.attributes.font;- const exactFont = fontAttribute === undefined- ? undefined- : inline<FontArtifactRef>(- reference(element, "font", mediaTypes.fontArtifact, resolveReference),- `${element.name}.font`,- );- if (exactFont !== undefined) assertFontArtifactRef(exactFont, `${element.name}.font`);- const style = fineCaptionStyle(id, recipe, exactFont);+ const style = fineCaptionStyle(id, recipe, exactFonts(element, resolveReference));return {records: [{ id, type: captionTypes.style, value: { kind: "inline", value: style }, range: element.range }],components: [],diff --git a/packages/caption-fine/src/types.ts b/packages/caption-fine/src/types.tsindex ee3e9fd6..6cf17a87 100644--- a/packages/caption-fine/src/types.ts+++ b/packages/caption-fine/src/types.ts@@ -43,7 +43,7 @@ export type FineCaptionParameters = {readonly fontSizePx: number;readonly fontWeight: number;readonly fontStyle: "normal" | "italic" | "oblique";- readonly exactFont?: FontArtifactRef;+ readonly exactFonts?: readonly FontArtifactRef[];};readonly basePaint: FineCaptionGlyphPaint;readonly activePaint: FineCaptionGlyphPaint;diff --git a/packages/caption-fine/test/caption-fine.test.ts b/packages/caption-fine/test/caption-fine.test.tsindex b1f6cf45..16aa5df6 100644--- a/packages/caption-fine/test/caption-fine.test.ts+++ b/packages/caption-fine/test/caption-fine.test.ts@@ -205,7 +205,7 @@ test("an exact Font is explicit Style input and reaches every base and active glconst style = fineCaptionStyle("font", {...recipe,properties: { ...recipe.properties, karaoke: "current", "active-fill": "#FFD54A" },- }, exactFont);+ }, [exactFont]);const program = resolveCaptionProgram(display, "font-program", style, []);const projection: TimedCaptionProjection = {contract: "svml.timed-caption-projection@1",@@ -227,7 +227,18 @@ test("an exact Font is explicit Style input and reaches every base and active glfor (const glyph of glyphs) {if (glyph.kind === "text") assert.deepEqual(glyph.fonts, [exactFont]);}- assert.throws(() => fineCaptionStyle("mismatch", recipe, { ...exactFont, weight: 700 }), /must match/u);+ assert.throws(() => fineCaptionStyle("mismatch", recipe, [{ ...exactFont, weight: 700 }]), /must match/u);+});++test("an ordered exact Font stack is preserved and rejects incompatible or duplicate fallbacks", () => {+ const fallback: FontArtifactRef = {+ ...exactFont,+ artifact: { ...exactFont.artifact, digest: digestOf("caption-fine:test-fallback") },+ };+ const parameters = fineCaptionParameters(recipe, [exactFont, fallback]);+ assert.deepEqual(parameters.typography.exactFonts, [exactFont, fallback]);+ assert.throws(() => fineCaptionParameters(recipe, [exactFont, exactFont]), /duplicate face/u);+ assert.throws(() => fineCaptionParameters(recipe, [exactFont, { ...fallback, style: "italic" }]), /must match/u);});test("current/trail by step/wipe have four distinct frame-exact Atom histories", () => {diff --git a/packages/hyperframes/test/browser-visual.test.ts b/packages/hyperframes/test/browser-visual.test.tsindex 8a1b09e1..92d9b3f1 100644--- a/packages/hyperframes/test/browser-visual.test.ts+++ b/packages/hyperframes/test/browser-visual.test.ts@@ -24,6 +24,10 @@ import type { SvsRecipe } from "@narratage/svs";const enabled = process.env.SVML_BROWSER_TESTS === "1";const localFont = process.env.SVML_TEST_FONT_PATH?? (process.platform === "darwin" ? "/System/Library/Fonts/SFNSMono.ttf" : undefined);+const cjkFont = process.env.SVML_TEST_CJK_FONT_PATH+ ?? (process.platform === "darwin" ? "/System/Library/Fonts/Supplemental/Arial Unicode.ttf" : undefined);+const emojiFont = process.env.SVML_TEST_EMOJI_FONT_PATH+ ?? (process.platform === "darwin" ? "/System/Library/Fonts/Apple Symbols.ttf" : undefined);const hyperframesCli = createRequire(path.join(process.cwd(), "packages/provider-hyperframes-local/package.json")).resolve("hyperframes/bin/hyperframes.mjs");@@ -117,6 +121,31 @@ function yellowPixelsByColumns(file: string, width: number, height: number, colureturn counts;}+function decodedRgba(file: string, width: number, height: number): Buffer {+ const decoded = spawnSync("ffmpeg", [+ "-v", "error", "-i", file, "-f", "rawvideo", "-pix_fmt", "rgba", "pipe:1",+ ], { encoding: "buffer", timeout: 30_000 });+ assert.equal(decoded.status, 0, decoded.stderr.toString());+ assert.equal(decoded.stdout.byteLength, width * height * 4);+ return decoded.stdout;+}++function matchingPixels(+ rgba: Buffer,+ width: number,+ region: { readonly left: number; readonly top: number; readonly right: number; readonly bottom: number },+ predicate: (red: number, green: number, blue: number, alpha: number) => boolean,+): number {+ let count = 0;+ for (let y = region.top; y < region.bottom; y += 1) {+ for (let x = region.left; x < region.right; x += 1) {+ const index = (y * width + x) * 4;+ if (predicate(rgba[index]!, rgba[index + 1]!, rgba[index + 2]!, rgba[index + 3]!)) count += 1;+ }+ }+ return count;+}+test("locked font and straight-alpha Surface survive one real Hyperframes browser frame", {skip: !enabled || localFont === undefined,timeout: 120_000,@@ -315,7 +344,7 @@ test("Fine Caption exact font, wrapping and all karaoke modes survive real browskaraoke: mode, "karaoke-transition": transition, "active-fill": "#FFD54A",},};- const style = fineCaptionStyle(`${mode}-${transition}`, recipe, font);+ const style = fineCaptionStyle(`${mode}-${transition}`, recipe, [font]);const program = resolveCaptionProgram(display, `${mode}-${transition}-program`, style, []);const projection: TimedCaptionProjection = {contract: "svml.timed-caption-projection@1",@@ -366,3 +395,118 @@ test("Fine Caption exact font, wrapping and all karaoke modes survive real browsawait rm(temp, { recursive: true, force: true });}});++test("Fine Caption exact fallbacks render CJK, emoji and independent stroke, shadow and glow Paint", {+ skip: !enabled || localFont === undefined || cjkFont === undefined || emojiFont === undefined,+ timeout: 120_000,+}, async () => {+ assert(localFont !== undefined && cjkFont !== undefined && emojiFont !== undefined);+ const temp = await mkdtemp(path.join(os.tmpdir(), "svml-caption-fine-multilingual-"));+ try {+ const width = 720;+ const height = 320;+ const durationSec = 1 / 30;+ const space = sealProgramSpace({+ contract: "svml.program-space@1",+ durationSec,+ frameRate: { numerator: 30, denominator: 1 },+ });+ const fontPaths = [localFont, cjkFont, emojiFont] as const;+ const fontBytes = await Promise.all(fontPaths.map(async (file) =>+ await import("node:fs/promises").then(({ readFile }) => readFile(file))));+ const fonts: FontArtifactRef[] = fontBytes.map((bytes) => ({+ contract: "svml.font-artifact@1",+ artifact: { kind: "blob", digest: digest(bytes), size: bytes.byteLength, mediaType: "font/ttf" },+ weight: 400,+ style: "normal",+ }));+ const base = {+ "cue-min-words": 1, "cue-max-words": 8,+ "stack-order": 20, width: 0.4,+ "anchor-x": "center", "anchor-y": "center",+ font: "Exact Multilingual Stack", weight: 400, size: 72, "line-height": 1,+ align: "center", fill: "#FFFFFF",+ background: "#00000000", padding: "0 0", radius: 0,+ } as const;+ const makeTrack = (+ id: string,+ text: string,+ properties: Readonly<Record<string, string | number>>,+ ) => {+ const narrative = parseScript(`${id}.svml`, `<line>${text}</line>`);+ const display = captionDisplaySequence(narrative, `${id}.caption`);+ const recipe: SvsRecipe = {+ contract: "svml.svs-recipe@1",+ path: `caption.${id}`,+ properties: { ...base, ...properties },+ };+ const style = fineCaptionStyle(id, recipe, fonts);+ const program = resolveCaptionProgram(display, `${id}-program`, style, []);+ const projection: TimedCaptionProjection = {+ contract: "svml.timed-caption-projection@1",+ displaySequenceId: display.id,+ cues: [{+ id: `${id}-cue`, runId: program.runs[0]!.id, styleId: style.id, segmentId: "line",+ startSec: 0, endSec: durationSec,+ atoms: display.atoms.map((atom) => ({ atomId: atom.id, startSec: 0, endSec: durationSec })),+ fields: [],+ }],+ };+ return renderFineCaption(projection, program, display, space);+ };+ const tracks = [+ makeTrack("cjk", "世界", { x: 0.25, y: 0.28 }),+ makeTrack("emoji", "<🌐 🎤 | globe microphone>", { x: 0.75, y: 0.28 }),+ makeTrack("paint", "SVML", {+ x: 0.5, y: 0.75, width: 0.7, size: 76,+ "stroke-color": "#FF0000", "stroke-width": 3,+ "shadow-color": "#0000FF", "shadow-opacity": 1,+ "shadow-x": 14, "shadow-y": 10, "shadow-blur": 0,+ "glow-color": "#00FF00", "glow-opacity": 1, "glow-blur": 10,+ }),+ ];+ const document = compileHyperframesDocument(sealComposition({+ contract: "svml.composition@1",+ id: "caption-fine-multilingual",+ canvas: { width, height, clearColor: "#000000" },+ tracks,+ }), space);+ assert.deepEqual(+ new Set(document.artifacts.map((artifact) => artifact.digest)),+ new Set(fonts.map((font) => font.artifact.digest)),+ );+ const names = ["latin.ttf", "cjk.ttf", "emoji.ttf"] as const;+ await Promise.all(fontPaths.map(async (file, index) => await copyFile(file, path.join(temp, names[index]!))));+ const paths = new Map(fonts.map((font, index) => [font.artifact.digest, `./${names[index]!}`]));+ await writeFile(path.join(temp, "index.html"), materializeHyperframesHtml(document, (artifact) => {+ const materialized = paths.get(artifact.digest);+ if (materialized === undefined) throw new Error(`Unexpected multilingual Artifact ${artifact.digest}`);+ return materialized;+ }));+ const output = path.join(temp, "frames");+ await mkdir(output);+ const render = spawnSync(process.execPath, [+ hyperframesCli, "render", temp,+ "--format", "png-sequence", "--output", output, "--fps", "30", "--workers", "1",+ "--no-browser-gpu", "--no-best-effort", "--quiet",+ ], { encoding: "utf8", timeout: 110_000 });+ assert.equal(render.status, 0, `${render.stdout}\n${render.stderr}`);+ const frames = await collectPngs(output);+ assert.equal(frames.length, 1);+ const rgba = decodedRgba(frames[0]!, width, height);+ const visible = (red: number, green: number, blue: number) => red + green + blue > 180;+ assert.ok(matchingPixels(rgba, width, { left: 0, top: 0, right: width / 2, bottom: height / 2 }, visible) > 100,+ "the exact CJK fallback did not paint its glyphs");+ assert.ok(matchingPixels(rgba, width, { left: width / 2, top: 0, right: width, bottom: height / 2 }, visible) > 100,+ "the exact emoji fallback did not paint its glyphs");+ const paintRegion = { left: 0, top: height / 2, right: width, bottom: height };+ assert.ok(matchingPixels(rgba, width, paintRegion, (red, green, blue) => red > 150 && green < 120 && blue < 120) > 100,+ "stroke Paint did not produce red pixels");+ assert.ok(matchingPixels(rgba, width, paintRegion, (red, green, blue) => blue > 150 && red < 120 && green < 120) > 100,+ "shadow Paint did not produce blue pixels");+ assert.ok(matchingPixels(rgba, width, paintRegion, (red, green, blue) => green > 50 && red < 120 && blue < 120) > 100,+ "glow Paint did not produce green pixels");+ } finally {+ await rm(temp, { recursive: true, force: true });+ }+});diff --git a/packages/video-cli/test/cli.test.ts b/packages/video-cli/test/cli.test.tsindex 167f72cc..5ba32464 100644--- a/packages/video-cli/test/cli.test.ts+++ b/packages/video-cli/test/cli.test.ts@@ -109,11 +109,12 @@ test("official video CLI checks a real Script source through the Node compiler h]);});-test("author source binds exact Font bytes to a Fine Caption Style", async () => {+test("author source binds an ordered exact Font stack to a Fine Caption Style", async () => {const root = await mkdtemp(join(tmpdir(), "svml-cli-caption-font-"));const file = join(root, "main.svml");const fontBytes = new Uint8Array([119, 79, 70, 50, 0, 1, 0, 0]);await writeFile(join(root, "caption.woff2"), fontBytes);+ await writeFile(join(root, "caption-fallback.woff2"), new Uint8Array([...fontBytes, 1]));await writeFile(join(root, "studio.svs"), `<?svml using="@narratage/svs@1"?><sheet version="1">caption.primary {@@ -130,7 +131,10 @@ test("author source binds exact Font bytes to a Fine Caption Style", async () =><import as="studio" source="./studio.svs"/><media:Font id="caption-font" src="./caption.woff2" weight="600" style="normal"/>- <caption-fine:Style id="primary-caption" recipe={studio.caption.primary} font={caption-font}/>+ <media:Font id="caption-fallback" src="./caption-fallback.woff2" weight="600" style="normal"/>+ <caption-fine:Style id="primary-caption" recipe={studio.caption.primary} font={caption-font}>+ <caption-fine:Fallback font={caption-fallback}/>+ </caption-fine:Style></svml>`, "utf8");let output = "";@@ -141,6 +145,7 @@ test("author source binds exact Font bytes to a Fine Caption Style", async () =>};assert.equal(result.ok, true);assert.equal(result.exports.some((item) => item.name === "caption-font" && item.kind === "record"), true);+ assert.equal(result.exports.some((item) => item.name === "caption-fallback" && item.kind === "record"), true);assert.equal(result.exports.some((item) => item.name === "primary-caption" && item.kind === "record"), true);});diff --git a/spec/caption-fine.md b/spec/caption-fine.mdindex af514180..0c2b9562 100644--- a/spec/caption-fine.md+++ b/spec/caption-fine.md@@ -1,6 +1,6 @@# Fine Caption Style Family-Status: complete public design recorded; implementation proceeds by the evidence gates below.+Status: implemented pre-release Style family with complete browser evidence for the declared surface.## Purpose and boundary@@ -52,20 +52,36 @@ maximum; it is never split to satisfy a number.- `line-height`, `letter-spacing`, `word-gap`- absolute `stack-order`-The Cue naturally wraps only between Atoms. Words inside one Atom never wrap apart. A hard-`max-lines` control is intentionally unavailable until browser-measured layout can fail the build-rather than silently clip or truncate authored text. Exact font bytes are now available; clipping-is still forbidden.+The Cue naturally wraps only between Atoms. Words inside one Atom never wrap apart. Fine has no+`max-lines` property: a hard line limit would either discard author text or smuggle browser+measurement into deterministic lowering. Fine never clips or truncates. Authors control density+with Cue bounds, width and font size. A future hard layout assertion, if one is genuinely needed,+must be a separately connected component whose failure is explicit in the graph.### 3. Typography- `font`, `weight`, `size`, `font-style: normal | italic | oblique`The Recipe's `font` property is a readable family label and an environment fallback. For a-reproducible build the author declares exact bytes with `<media:Font>` and passes that value through-the Style's optional `font=` input. The declared face weight/style must equal the Recipe. Fine puts-that `FontArtifactRef` only on its terminal text elements; Caption, Core and unrelated graph values-remain unchanged.+reproducible build the author declares exact bytes with `<media:Font>`, passes the primary face+through `font=`, and may add ordered `<caption-fine:Fallback>` children for CJK, emoji or other+glyph coverage:++```svml+<caption-fine:Style id="primary" recipe={studio.caption.primary} font={latin}>+ <caption-fine:Fallback font={cjk}/>+ <caption-fine:Fallback font={symbols}/>+</caption-fine:Style>+```++Every face must declare the Recipe's exact weight/style and duplicate bytes are rejected. Fine puts+this ordered `FontArtifactRef` stack only on its terminal text elements; Caption, Core and unrelated+graph values remain unchanged. Omitting `font=` is an explicit environment-bound prototype path,+not a Runtime font-selection policy.++CJK speech may be authored directly. A display-only emoji still needs explicit speech+correspondence, for example `<🌐 | globe>`; Script correctly refuses to invent a spoken token for a+bare symbol. This is timing truth, not a font limitation.### 4. Base glyph Paint@@ -143,17 +159,17 @@ complete immutable parameter object:Unknown properties are rejected. Defaults are package implementation policy and therefore coveredby its implementation digest; they are not hidden Runtime behavior.-## Evidence gates and implementation order+## Completed evidence gates-This is one complete design, delivered progressively rather than three incompatible versions:+The complete design was delivered progressively rather than as incompatible versions:1. **Resolved model and static lowering** — complete parameters, anchors, layout, base/active Paint,Cue box and strict validation.2. **Timed lowering** — current/trail, step/wipe, Cue fades, Atom reveal and active scale using onlyproven whole-Atom time.-3. **Reproducibility freeze** — exact Font Artifact input, multiline wrapping and all four karaoke- modes have a real browser witness. Remaining work is broader CJK/emoji and outline/glow pixel- evidence, then deciding whether measured `max-lines` can be exposed without clipping.+3. **Reproducibility evidence** — an ordered exact Font Artifact stack, CJK, emoji/symbol fallback,+ multiline wrapping, outline, shadow, glow and all four karaoke modes have real browser/pixel+ witnesses. `max-lines` was deliberately rejected rather than deferred.No gate changes Core or common Caption. Exact font selection is an explicit author-graph referencebetween the Media Font Surface and the Fine Style Surface, not metadata propagated through thediff --git a/spec/track-expressiveness.md b/spec/track-expressiveness.mdindex b5f68755..4abd9a24 100644--- a/spec/track-expressiveness.md+++ b/spec/track-expressiveness.md@@ -121,10 +121,12 @@ executable rather than package-family patches:still/frame timing to Blob bytes. Animated Surfaces must exactly share the containing Present'sframe count and ProgramSpace rate.-`packages/hyperframes/test/browser-visual.test.ts` additionally drives one real Hyperframes browser-frame: a real content-addressed font paints glyphs and a 50% straight-alpha PNG composites over a-blue Track at the expected pixel values. This opt-in host test is run with-`SVML_BROWSER_TESTS=1`; it proves the current local renderer path, not every future hosted Runtime.+`packages/hyperframes/test/browser-visual.test.ts` additionally drives real Hyperframes browser+frames: content-addressed fonts paint Latin, CJK and emoji/symbol glyphs through an ordered fallback+stack; Fine Caption proves multiline wrapping, outline/shadow/glow and every karaoke mode; and a+50% straight-alpha PNG composites over a blue Track at the expected pixel values. This opt-in host+test is run with `SVML_BROWSER_TESTS=1`; it proves the current local renderer path, not every future+hosted Runtime.The IR style vocabulary is now closed rather than arbitrary CSS: components cannot add an unknownproperty, environment-dependent value or alternate browser language without changing the protocoldiff --git a/spec/visual-ir.md b/spec/visual-ir.mdindex 4377d061..d64e4d39 100644--- a/spec/visual-ir.md+++ b/spec/visual-ir.md@@ -110,9 +110,10 @@ IR, not fields added to the IR.The identifier and closed vocabulary are executable, but v1 remains a candidate until:-1. official Text and Caption lowerers require exact font Artifacts or materialized glyph Surfaces;-2. old production text/media witnesses have real browser pixel tests, including CJK, emoji,- multiline decoration, focal sampling, alpha and overflow;+1. the official Text lowerer requires exact font Artifacts or materialized glyph Surfaces; Fine+ Caption already exposes an exact ordered font stack while retaining an explicit prototype path;+2. remaining old production Text/media witnesses have real browser pixel tests for their own+ multiline decoration, focal sampling, alpha and overflow; Fine Caption's CJK/emoji matrix is complete;3. the Runtime receipt binds the exact renderer implementation used for layout;4. Surface bytes are checked against their declared dimensions, timing, color and alpha facts;5. a separately installed Track package passes without changing Core, Film or HyperFrames code.