Font selector

This commit is contained in:
2026-05-22 17:22:57 +10:00
parent c5f0a9df0e
commit 283f38dddb
15 changed files with 276 additions and 34 deletions

View File

@@ -49,6 +49,7 @@ void TestValidManifest()
const std::filesystem::path root = MakeTestRoot();
WriteFile(root / "look" / "mask.png", "not a real png, but enough for existence checks");
WriteFile(root / "look" / "Inter.ttf", "not a real font, but enough for existence checks");
WriteFile(root / "look" / "Mono.ttf", "not a real font, but enough for existence checks");
WriteShaderPackage(root, "look", R"({
"id": "look-01",
"name": "Look 01",
@@ -56,15 +57,18 @@ void TestValidManifest()
"category": "Tests",
"entryPoint": "shadeVideo",
"textures": [{ "id": "maskTex", "path": "mask.png" }],
"fonts": [{ "id": "inter", "path": "Inter.ttf" }],
"fonts": [
{ "id": "inter", "path": "Inter.ttf" },
{ "id": "mono", "path": "Mono.ttf" }
],
"temporal": { "enabled": true, "historySource": "source", "historyLength": 8 },
"feedback": { "enabled": true },
"parameters": [
{ "id": "gain", "label": "Gain", "description": "Scales the output intensity.", "type": "float", "default": 0.5, "min": 0, "max": 1 },
{ "id": "titleText", "label": "Title", "type": "text", "default": "LIVE", "font": "inter", "maxLength": 32 },
{ "id": "mode", "label": "Mode", "type": "enum", "default": "soft", "options": [
{ "value": "soft", "label": "Soft" },
{ "value": "hard", "label": "Hard" }
{ "id": "titleText", "label": "Title", "type": "text", "default": "LIVE", "font": "inter", "fontParameter": "mode", "maxLength": 32 },
{ "id": "mode", "label": "Mode", "type": "enum", "default": "inter", "options": [
{ "value": "inter", "label": "Inter" },
{ "value": "mono", "label": "Mono" }
] },
{ "id": "flash", "label": "Flash", "type": "trigger" }
]
@@ -76,12 +80,13 @@ void TestValidManifest()
Expect(registry.ParseManifest(root / "look" / "shader.json", package, error), "valid manifest parses");
Expect(package.id == "look-01", "manifest id is preserved");
Expect(package.textureAssets.size() == 1 && package.textureAssets[0].id == "maskTex", "texture assets parse");
Expect(package.fontAssets.size() == 1 && package.fontAssets[0].id == "inter", "font assets parse");
Expect(package.fontAssets.size() == 2 && package.fontAssets[0].id == "inter", "font assets parse");
Expect(package.temporal.enabled && package.temporal.effectiveHistoryLength == 4, "temporal history is capped");
Expect(package.feedback.enabled && package.feedback.writePassId == "main", "feedback defaults to the implicit main pass");
Expect(package.parameters.size() == 4, "parameters parse");
Expect(package.parameters[0].description == "Scales the output intensity.", "parameter descriptions parse");
Expect(package.parameters[1].type == ShaderParameterType::Text && package.parameters[1].defaultTextValue == "LIVE", "text parameter parses");
Expect(package.parameters[1].fontParameterId == "mode", "text font selector parameter parses");
Expect(package.parameters[3].type == ShaderParameterType::Trigger, "trigger parameter parses");
Expect(package.passes.size() == 1 && package.passes[0].id == "main", "legacy manifests get an implicit main pass");