@native-sdk/cli 0.5.2 → 0.5.4

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.
Files changed (123) hide show
  1. package/build/app.zig +41 -1
  2. package/build.zig +264 -3
  3. package/native-sdk.d.ts +17 -1
  4. package/package.json +9 -9
  5. package/packages/core/package-lock.json +2 -2
  6. package/packages/core/package.json +1 -1
  7. package/packages/core/rt/rt.zig +138 -3
  8. package/packages/core/sdk/core.ts +225 -3
  9. package/packages/core/sdk/events.ts +39 -2
  10. package/packages/core/src/checker.ts +1 -1
  11. package/packages/core/src/emitter.ts +2625 -262
  12. package/packages/core/src/infer.ts +53 -7
  13. package/skill-data/automation/SKILL.md +7 -4
  14. package/skill-data/core/references/app-model-runtime.md +3 -0
  15. package/skill-data/native-ui/SKILL.md +4 -2
  16. package/skill-data/ts-core/SKILL.md +9 -1
  17. package/src/app_runner/root.zig +106 -1
  18. package/src/app_runner/ts_core_main.zig +4 -0
  19. package/src/automation/protocol.zig +20 -1
  20. package/src/embed/host.zig +27 -0
  21. package/src/embed/tests.zig +187 -0
  22. package/src/embed/ui_host.zig +4 -0
  23. package/src/platform/linux/gtk_host.c +112 -3
  24. package/src/platform/linux/root.zig +71 -0
  25. package/src/platform/macos/appkit_host.h +59 -2
  26. package/src/platform/macos/appkit_host.m +663 -34
  27. package/src/platform/macos/cef_host.mm +262 -10
  28. package/src/platform/macos/root.zig +126 -4
  29. package/src/platform/null_platform.zig +298 -5
  30. package/src/platform/null_platform_tests.zig +39 -0
  31. package/src/platform/root.zig +36 -0
  32. package/src/platform/types.zig +247 -8
  33. package/src/platform/windows/root.zig +134 -0
  34. package/src/platform/windows/webview2_host.cpp +152 -40
  35. package/src/primitives/app_manifest/comptime_scene.zig +5 -0
  36. package/src/primitives/app_manifest/root.zig +1 -0
  37. package/src/primitives/app_manifest/types.zig +32 -0
  38. package/src/primitives/canvas/chart.zig +7 -7
  39. package/src/primitives/canvas/chart_tests.zig +66 -0
  40. package/src/primitives/canvas/commands.zig +48 -0
  41. package/src/primitives/canvas/events.zig +161 -0
  42. package/src/primitives/canvas/font_ttf.zig +155 -8
  43. package/src/primitives/canvas/font_ttf_tests.zig +686 -0
  44. package/src/primitives/canvas/reference.zig +67 -8
  45. package/src/primitives/canvas/render_fingerprints.zig +8 -0
  46. package/src/primitives/canvas/root.zig +25 -0
  47. package/src/primitives/canvas/tests.zig +1 -0
  48. package/src/primitives/canvas/ui.zig +46 -9
  49. package/src/primitives/canvas/ui_markup.zig +82 -34
  50. package/src/primitives/canvas/ui_markup_binary.zig +4 -1
  51. package/src/primitives/canvas/ui_markup_binary_tests.zig +25 -0
  52. package/src/primitives/canvas/ui_markup_compiled.zig +63 -11
  53. package/src/primitives/canvas/ui_markup_compiled_tests.zig +88 -0
  54. package/src/primitives/canvas/ui_markup_contract.zig +10 -1
  55. package/src/primitives/canvas/ui_markup_contract_tests.zig +50 -0
  56. package/src/primitives/canvas/ui_markup_huge_document_tests.zig +154 -0
  57. package/src/primitives/canvas/ui_markup_tests.zig +55 -9
  58. package/src/primitives/canvas/ui_markup_view.zig +81 -14
  59. package/src/primitives/canvas/ui_markup_view_tests.zig +219 -7
  60. package/src/primitives/canvas/ui_schema.zig +29 -0
  61. package/src/primitives/canvas/ui_schema_tests.zig +11 -11
  62. package/src/primitives/canvas/ui_tests.zig +31 -0
  63. package/src/primitives/canvas/vector.zig +258 -141
  64. package/src/primitives/canvas/widget_access.zig +1 -1
  65. package/src/primitives/canvas/widget_builtin_tests.zig +129 -0
  66. package/src/primitives/canvas/widget_layout.zig +9 -4
  67. package/src/primitives/canvas/widget_render.zig +78 -40
  68. package/src/primitives/canvas/widget_render_controls.zig +15 -4
  69. package/src/primitives/canvas/widget_semantics.zig +6 -1
  70. package/src/primitives/canvas/widget_semantics_tests.zig +168 -0
  71. package/src/primitives/canvas/widget_text_input.zig +118 -10
  72. package/src/primitives/canvas/widgets.zig +16 -0
  73. package/src/root.zig +12 -0
  74. package/src/runtime/api.zig +15 -0
  75. package/src/runtime/automation_commands.zig +33 -0
  76. package/src/runtime/automation_widget_dispatch.zig +64 -0
  77. package/src/runtime/bridge_payload.zig +7 -0
  78. package/src/runtime/bridge_responses.zig +5 -0
  79. package/src/runtime/builtin_bridge.zig +9 -4
  80. package/src/runtime/canvas_font_tests.zig +711 -5
  81. package/src/runtime/canvas_fonts.zig +120 -25
  82. package/src/runtime/canvas_frame_helpers.zig +15 -0
  83. package/src/runtime/canvas_image_tests.zig +221 -0
  84. package/src/runtime/canvas_images.zig +78 -19
  85. package/src/runtime/canvas_limits.zig +44 -8
  86. package/src/runtime/canvas_widget_clipboard_tests.zig +123 -0
  87. package/src/runtime/canvas_widget_context_menu_tests.zig +55 -0
  88. package/src/runtime/canvas_widget_events.zig +24 -4
  89. package/src/runtime/canvas_widget_runtime.zig +24 -7
  90. package/src/runtime/canvas_widget_state.zig +6 -1
  91. package/src/runtime/canvas_widget_text_tests.zig +277 -0
  92. package/src/runtime/core.zig +148 -9
  93. package/src/runtime/effects.zig +1664 -43
  94. package/src/runtime/effects_fetch_tests.zig +89 -1
  95. package/src/runtime/effects_file_tests.zig +41 -1
  96. package/src/runtime/effects_image_tests.zig +1304 -0
  97. package/src/runtime/effects_tests.zig +153 -0
  98. package/src/runtime/flow.zig +44 -0
  99. package/src/runtime/gpu_surface_events.zig +7 -0
  100. package/src/runtime/media_surface.zig +726 -0
  101. package/src/runtime/media_surface_tests.zig +1476 -0
  102. package/src/runtime/root.zig +20 -0
  103. package/src/runtime/session_blobs.zig +689 -0
  104. package/src/runtime/session_journal.zig +111 -20
  105. package/src/runtime/session_record.zig +27 -2
  106. package/src/runtime/session_replay.zig +168 -16
  107. package/src/runtime/session_tests.zig +2118 -4
  108. package/src/runtime/shell_layout.zig +7 -0
  109. package/src/runtime/testdata/fonts/NotoSansSC-Receipt.ttf +0 -0
  110. package/src/runtime/testdata/fonts/OFL.txt +93 -0
  111. package/src/runtime/tests.zig +3 -0
  112. package/src/runtime/ts_core_host.zig +439 -4
  113. package/src/runtime/ts_core_host_tests.zig +41 -0
  114. package/src/runtime/ts_ui_app.zig +63 -0
  115. package/src/runtime/ui_app.zig +169 -6
  116. package/src/runtime/ui_app_tests.zig +334 -0
  117. package/src/runtime/ui_app_window_tests.zig +468 -0
  118. package/src/runtime/window_command_bridge_tests.zig +117 -0
  119. package/src/runtime/window_storage.zig +32 -0
  120. package/src/runtime/window_views.zig +61 -1
  121. package/src/tooling/manifest.zig +75 -0
  122. package/src/tooling/raw_manifest.zig +2 -0
  123. package/src/tooling/templates.zig +219 -1
@@ -1,8 +1,11 @@
1
1
  //! Runtime canvas font registry tests: registration validation and
2
2
  //! capacity bounds (loud, one-past-budget), hostile/truncated font
3
- //! files, the font-aware measure provider, pixel parity between the
4
- //! present path and the reference screenshot path for a registered
5
- //! face, and the UiApp `Options.fonts` startup seam.
3
+ //! files, the registration-time glyph-budget gate (over-declaring
4
+ //! `maxp` refused whole; the real Noto Sans JP accepted and outlining
5
+ //! dense kanji when the /tmp fixture is present), the font-aware
6
+ //! measure provider, pixel parity between the present path and the
7
+ //! reference screenshot path for a registered face, and the UiApp
8
+ //! `Options.fonts` startup seam.
6
9
  //!
7
10
  //! The registered fixture is the ALREADY-BUNDLED Geist Mono bytes
8
11
  //! (`canvas.font_ttf.geist_mono_bytes`) under a registered id: the
@@ -86,6 +89,75 @@ test "canvas font registry validates ids, bytes, and capacity" {
86
89
  try std.testing.expectEqual(registered_font_id, resources[0].id);
87
90
  }
88
91
 
92
+ test "a fresh runtime allocates zero font bytes until a registration happens" {
93
+ const harness = try startedGpuHarness(std.testing.allocator);
94
+ defer harness.destroy(std.testing.allocator);
95
+ var app_state: RegistryApp = .{};
96
+
97
+ // Count every runtime-allocator call: construction, startup, and
98
+ // frames perform NONE — font byte storage is on-demand at
99
+ // registration, so a fontless runtime carries zero font bytes. (The
100
+ // regression pinned here: a reservation-shaped slot pool at the
101
+ // 24 MiB CJK bound embedded 192 MiB in every Runtime, doubling the
102
+ // docs wasm preview host's per-tile memory before any font existed.)
103
+ // The ownership allocator is frozen at init, so the test re-freezes
104
+ // the field directly — equivalent to constructing with the counting
105
+ // allocator, and safe exactly because no owned bytes exist yet.
106
+ var counting = std.testing.FailingAllocator.init(std.testing.allocator, .{});
107
+ harness.runtime.owned_allocator = counting.allocator();
108
+ try harness.start(app_state.app());
109
+ try std.testing.expectEqual(@as(usize, 0), counting.allocations);
110
+
111
+ // Even an allocator that refuses everything leaves the runtime
112
+ // fully operational until a registration demands memory — and that
113
+ // failure is loud and recoverable, never a partial slot. (Still
114
+ // nothing owned, so re-freezing stays equivalent to init capture.)
115
+ var failing = std.testing.FailingAllocator.init(std.testing.allocator, .{ .fail_index = 0 });
116
+ harness.runtime.owned_allocator = failing.allocator();
117
+ try std.testing.expectError(error.OutOfMemory, harness.runtime.registerCanvasFont(registered_font_id, mono_bytes));
118
+ try std.testing.expectEqual(@as(usize, 0), harness.runtime.registeredCanvasFontCount());
119
+
120
+ // Registration is the first allocation: exactly one, exactly the
121
+ // file's size (freed by Runtime.deinit through harness.destroy —
122
+ // the leak-checked test allocator backs it).
123
+ harness.runtime.owned_allocator = counting.allocator();
124
+ try harness.runtime.registerCanvasFont(registered_font_id, mono_bytes);
125
+ try std.testing.expectEqual(@as(usize, 1), counting.allocations);
126
+ try std.testing.expectEqual(mono_bytes.len, counting.allocated_bytes);
127
+ }
128
+
129
+ test "deinit frees font bytes through the init-frozen allocator even after options.allocator is mutated" {
130
+ const harness = try startedGpuHarness(std.testing.allocator);
131
+ defer harness.destroy(std.testing.allocator);
132
+ var app_state: RegistryApp = .{};
133
+ try harness.start(app_state.app());
134
+
135
+ // Freeze a counting allocator as the runtime's owner (equivalent to
136
+ // constructing with it — nothing is owned yet) and register a face
137
+ // through it.
138
+ var counting = std.testing.FailingAllocator.init(std.testing.allocator, .{});
139
+ harness.runtime.owned_allocator = counting.allocator();
140
+ try harness.runtime.registerCanvasFont(registered_font_id, mono_bytes);
141
+ try std.testing.expectEqual(@as(usize, 1), counting.allocations);
142
+ try std.testing.expectEqual(@as(usize, 0), counting.deallocations);
143
+
144
+ // The hazard under test: `Runtime.options` is public and mutable, so
145
+ // an embedder can swap `options.allocator` AFTER fonts registered.
146
+ // Ownership must not retarget — the deinit free has to hit the
147
+ // allocator that made the bytes, not whatever the option points at
148
+ // by teardown time.
149
+ var mutated = std.testing.FailingAllocator.init(std.testing.allocator, .{ .fail_index = 0 });
150
+ harness.runtime.options.allocator = mutated.allocator();
151
+ harness.runtime.deinit();
152
+
153
+ // Counts balance on the original identity; the mutated allocator
154
+ // saw zero activity in either direction.
155
+ try std.testing.expectEqual(counting.allocations, counting.deallocations);
156
+ try std.testing.expectEqual(counting.allocated_bytes, counting.freed_bytes);
157
+ try std.testing.expectEqual(@as(usize, 0), mutated.allocations);
158
+ try std.testing.expectEqual(@as(usize, 0), mutated.deallocations);
159
+ }
160
+
89
161
  test "hostile and truncated font files fail loud at registration and never corrupt the registry" {
90
162
  const harness = try startedGpuHarness(std.testing.allocator);
91
163
  defer harness.destroy(std.testing.allocator);
@@ -199,6 +271,167 @@ test "registered faces answer the batched advances seam identically to per-prefi
199
271
  }
200
272
  }
201
273
 
274
+ /// Byte offset of the `maxp` table in a TrueType file (test fixture
275
+ /// helper for building over-declaring faces out of the bundled bytes).
276
+ fn maxpTableOffset(bytes: []const u8) usize {
277
+ const table_count = std.mem.readInt(u16, bytes[4..6], .big);
278
+ var index: usize = 0;
279
+ while (index < table_count) : (index += 1) {
280
+ const record = 12 + index * 16;
281
+ if (std.mem.eql(u8, bytes[record .. record + 4], "maxp")) {
282
+ return std.mem.readInt(u32, bytes[record + 8 ..][0..4], .big);
283
+ }
284
+ }
285
+ unreachable; // the bundled faces always carry maxp
286
+ }
287
+
288
+ /// The bundled mono bytes with `maxp.maxPoints` patched one past the
289
+ /// glyph-point budget: a face that DECLARES denser glyphs than the
290
+ /// outline pipeline's budgets and must be refused whole at
291
+ /// registration, never degraded per glyph at render time.
292
+ fn overBudgetFontBytes(allocator: std.mem.Allocator) ![]u8 {
293
+ const patched = try allocator.dupe(u8, mono_bytes);
294
+ const maxp = maxpTableOffset(patched);
295
+ std.mem.writeInt(u16, patched[maxp + 6 ..][0..2], @intCast(canvas.font_ttf.max_glyph_points + 1), .big);
296
+ return patched;
297
+ }
298
+
299
+ /// The bundled mono bytes with `maxp.maxCompositePoints` (offset 10)
300
+ /// patched one past the flattened-composite budget: modest simple
301
+ /// maxima, composite flattening the path builder could not hold — the
302
+ /// exact face shape a simple-only gate would admit and then silently
303
+ /// block at render time.
304
+ fn overCompositeBudgetFontBytes(allocator: std.mem.Allocator) ![]u8 {
305
+ const patched = try allocator.dupe(u8, mono_bytes);
306
+ const maxp = maxpTableOffset(patched);
307
+ std.mem.writeInt(u16, patched[maxp + 10 ..][0..2], @intCast(canvas.font_ttf.max_composite_points + 1), .big);
308
+ return patched;
309
+ }
310
+
311
+ test "a face declaring glyphs denser than the budgets is refused at registration" {
312
+ const harness = try startedGpuHarness(std.testing.allocator);
313
+ defer harness.destroy(std.testing.allocator);
314
+ var app_state: RegistryApp = .{};
315
+ try harness.start(app_state.app());
316
+
317
+ const patched = try overBudgetFontBytes(std.testing.allocator);
318
+ defer std.testing.allocator.free(patched);
319
+
320
+ try std.testing.expectError(error.FontExceedsGlyphBudgets, harness.runtime.registerCanvasFont(registered_font_id, patched));
321
+ try std.testing.expectEqual(@as(usize, 0), harness.runtime.registeredCanvasFontCount());
322
+
323
+ // The teaching machinery names the refusal: parse-reason carries the
324
+ // budget sentence, and the declared maxima expose the face's own
325
+ // numbers for callers that format (UiApp's fonts teaching).
326
+ try std.testing.expect(std.mem.indexOf(u8, canvas.font_ttf.parseFailureReason(patched).?, "budgets") != null);
327
+ const maxima = canvas.font_ttf.declaredGlyphMaxima(patched).?;
328
+ try std.testing.expectEqual(@as(u16, @intCast(canvas.font_ttf.max_glyph_points + 1)), maxima.points);
329
+ try std.testing.expect(!maxima.withinBudgets());
330
+
331
+ // No partial slot: the honest twin registers under the same id.
332
+ try harness.runtime.registerCanvasFont(registered_font_id, mono_bytes);
333
+ try std.testing.expectEqual(@as(usize, 1), harness.runtime.registeredCanvasFontCount());
334
+ }
335
+
336
+ test "a face declaring flattened composites denser than the budgets is refused at registration" {
337
+ const harness = try startedGpuHarness(std.testing.allocator);
338
+ defer harness.destroy(std.testing.allocator);
339
+ var app_state: RegistryApp = .{};
340
+ try harness.start(app_state.app());
341
+
342
+ // Simple maxima untouched (well within budget) — only the
343
+ // flattened-composite declaration is over. A gate reading simple
344
+ // maxima alone admits this face; its composites then overflow the
345
+ // reference path builder at render time and degrade to blocks, the
346
+ // exact silent failure registration-time validation forbids.
347
+ const patched = try overCompositeBudgetFontBytes(std.testing.allocator);
348
+ defer std.testing.allocator.free(patched);
349
+
350
+ try std.testing.expectError(error.FontExceedsGlyphBudgets, harness.runtime.registerCanvasFont(registered_font_id, patched));
351
+ try std.testing.expectEqual(@as(usize, 0), harness.runtime.registeredCanvasFontCount());
352
+
353
+ // The teaching names the composite budgets and the declared maxima
354
+ // expose the face's own composite numbers.
355
+ const reason = canvas.font_ttf.parseFailureReason(patched).?;
356
+ try std.testing.expect(std.mem.indexOf(u8, reason, "flattened composite") != null);
357
+ const maxima = canvas.font_ttf.declaredGlyphMaxima(patched).?;
358
+ try std.testing.expectEqual(@as(u16, @intCast(canvas.font_ttf.max_composite_points + 1)), maxima.composite_points);
359
+ try std.testing.expect(!maxima.withinBudgets());
360
+
361
+ // The unpatched twin registers: the gate reads the declaration, not
362
+ // the patch's collateral.
363
+ try harness.runtime.registerCanvasFont(registered_font_id, mono_bytes);
364
+ try std.testing.expectEqual(@as(usize, 1), harness.runtime.registeredCanvasFontCount());
365
+ }
366
+
367
+ test "the real Noto Sans JP face registers and outlines dense kanji (guarded by /tmp/NotoSansJP.ttf)" {
368
+ // Ground-truth end-to-end proof with the face the budgets were
369
+ // sized from: the Google Fonts TrueType build of Noto Sans JP
370
+ // (OFL). Font binaries stay out of the repo, so the fixture is a
371
+ // local download; environments without it skip.
372
+ const bytes = std.Io.Dir.cwd().readFileAlloc(
373
+ std.testing.io,
374
+ "/tmp/NotoSansJP.ttf",
375
+ std.testing.allocator,
376
+ .limited(canvas_limits.max_registered_canvas_font_bytes),
377
+ ) catch return error.SkipZigTest;
378
+ defer std.testing.allocator.free(bytes);
379
+
380
+ const harness = try startedGpuHarness(std.testing.allocator);
381
+ defer harness.destroy(std.testing.allocator);
382
+ var app_state: RegistryApp = .{};
383
+ try harness.start(app_state.app());
384
+
385
+ // Registration passes the byte bound, the maxp gate, and the host
386
+ // seam — the whole registration-time validation doctrine.
387
+ try harness.runtime.registerCanvasFont(registered_font_id, bytes);
388
+ const face = harness.runtime.registeredCanvasFontFace(registered_font_id).?;
389
+
390
+ // Everyday-dense kanji resolve to real outlines, not notdef blocks:
391
+ // 鬱 U+9B31 measures 237 points / 26 contours in this face — far
392
+ // past the old Latin-sized 128-point/24-contour budgets that made
393
+ // it render as a block.
394
+ const dense_kanji = [_]u21{ 0x9B31, 0x9A5A, 0x7C60, 0x9451 }; // 鬱 驚 籠 鑑
395
+ for (dense_kanji) |codepoint| {
396
+ const glyph = face.glyphIndex(codepoint);
397
+ try std.testing.expect(glyph != 0);
398
+ var builder = canvas.vector.PathBuilder(2048){};
399
+ try face.glyphOutline(glyph, canvas.Affine.identity(), &builder);
400
+ try std.testing.expect(builder.slice().len > 0);
401
+ }
402
+
403
+ // The dense outline rasterizes within the vector budgets at body
404
+ // and headline sizes.
405
+ const InkCounter = struct {
406
+ covered: usize = 0,
407
+ pub fn pixel(self: *@This(), x: i32, y: i32, coverage: f32) void {
408
+ _ = x;
409
+ _ = y;
410
+ if (coverage > 0) self.covered += 1;
411
+ }
412
+ };
413
+ for ([_]f32{ 16, 96 }) |size| {
414
+ const glyph = face.glyphIndex(0x9B31);
415
+ const scale = size / face.units_per_em;
416
+ var builder = canvas.vector.PathBuilder(2048){};
417
+ try face.glyphOutline(glyph, .{ .a = scale, .b = 0, .c = 0, .d = -scale, .tx = 4, .ty = size }, &builder);
418
+ var counter = InkCounter{};
419
+ try canvas.vector.fillPath(
420
+ builder.slice(),
421
+ canvas.Affine.identity(),
422
+ .nonzero,
423
+ canvas.vector.default_tolerance,
424
+ .{ .x0 = 0, .y0 = 0, .x1 = 128, .y1 = 128 },
425
+ &counter,
426
+ );
427
+ try std.testing.expect(counter.covered > 0);
428
+ }
429
+
430
+ // Layout measures the registered face's own advances for the kanji.
431
+ const provider = harness.runtime.textMeasureProvider().?;
432
+ try std.testing.expect(provider.measureWidth(registered_font_id, 16.0, "鬱") > 0);
433
+ }
434
+
202
435
  fn installFontFixtureWidgets(harness: anytype) !void {
203
436
  _ = try harness.runtime.createView(.{
204
437
  .window_id = 1,
@@ -277,8 +510,8 @@ test "a registered face renders pixel-identically on the present path and the re
277
510
 
278
511
  // ------------------------------------------------ UiApp Options.fonts
279
512
 
280
- const FontAppModel = struct { presses: u32 = 0 };
281
- const FontAppMsg = union(enum) { press: void };
513
+ const FontAppModel = struct { presses: u32 = 0, show_uncovered_cjk: bool = false };
514
+ const FontAppMsg = union(enum) { press: void, show_uncovered_cjk: void };
282
515
  const FontApp = ui_app_model.UiApp(FontAppModel, FontAppMsg);
283
516
 
284
517
  const font_app_canvas_label = "canvas";
@@ -286,6 +519,7 @@ const font_app_canvas_label = "canvas";
286
519
  fn fontAppUpdate(model: *FontAppModel, msg: FontAppMsg) void {
287
520
  switch (msg) {
288
521
  .press => model.presses += 1,
522
+ .show_uncovered_cjk => model.show_uncovered_cjk = true,
289
523
  }
290
524
  }
291
525
 
@@ -408,3 +642,475 @@ test "ui app declared font failures are teaching errors, not crashes or silent f
408
642
  try std.testing.expect(app_state.installed);
409
643
  try std.testing.expectEqual(first_errors, harness.runtime.dispatchErrorTotal());
410
644
  }
645
+
646
+ // ---------------------------------------------- the Chinese receipt
647
+
648
+ /// Committed CJK fixture: Noto Sans SC (OFL — the license rides beside
649
+ /// the file in testdata/fonts/OFL.txt), instanced at wght=400 from the
650
+ /// Google Fonts variable TrueType build and subsetted to exactly the
651
+ /// receipt string's four ideographs plus notdef (2.2 KB — the license
652
+ /// permits subsetting; full font binaries stay out of the repo). The
653
+ /// subset keeps the format-4 unicode cmap, real `glyf` outlines, and
654
+ /// the full font's truthful `maxp` declaration (584 points / 84
655
+ /// contours — past the old Latin-sized budgets, inside the CJK-sized
656
+ /// ones), so registration exercises the real gate and rendering inks
657
+ /// real Han ideograph outlines, deterministically, on every CI host.
658
+ const cjk_receipt_bytes = @embedFile("testdata/fonts/NotoSansSC-Receipt.ttf");
659
+
660
+ /// 你好世界 — "Hello, world".
661
+ const cjk_receipt_text = "\u{4F60}\u{597D}\u{4E16}\u{754C}";
662
+
663
+ /// 中文字体 — "Chinese font": four ideographs the subsetted fixture
664
+ /// face deliberately does NOT map (the subset carries exactly the
665
+ /// receipt string's four glyphs plus notdef; the test pins the gap
666
+ /// with glyphIndex() == 0 before relying on it). Rendered with the
667
+ /// SAME registered face, this string can only draw four notdef boxes
668
+ /// — the self-calibrating tofu baseline the receipt compares against.
669
+ const cjk_uncovered_text = "\u{4E2D}\u{6587}\u{5B57}\u{4F53}";
670
+
671
+ fn cjkAppView(ui: *FontApp.Ui, model: *const FontAppModel) FontApp.Ui.Node {
672
+ return ui.column(.{ .gap = 8, .padding = 12 }, .{
673
+ ui.text(.{}, if (model.show_uncovered_cjk) cjk_uncovered_text else cjk_receipt_text),
674
+ });
675
+ }
676
+
677
+ test "the Chinese receipt: a scaffold-shaped app registers a CJK face and renders real glyphs, not tofu" {
678
+ const harness = try TestHarness().create(std.testing.allocator, .{ .size = geometry.SizeF.init(240, 200) });
679
+ defer harness.destroy(std.testing.allocator);
680
+ harness.null_platform.gpu_surfaces = true;
681
+
682
+ // The scaffold shape: fonts declared on Options.fonts, tokens
683
+ // pointing the typography face slot at the registered id, Chinese
684
+ // text in the view.
685
+ const fonts = [_]FontApp.FontRegistration{.{
686
+ .id = registered_font_id,
687
+ .name = "NotoSansSC-Receipt.ttf",
688
+ .ttf = cjk_receipt_bytes,
689
+ }};
690
+ var options = fontAppOptions(&fonts);
691
+ options.view = cjkAppView;
692
+ const app_state = try std.testing.allocator.create(FontApp);
693
+ defer std.testing.allocator.destroy(app_state);
694
+ app_state.* = FontApp.init(std.testing.allocator, .{}, options);
695
+ defer app_state.deinit();
696
+ const app = app_state.app();
697
+ try harness.start(app);
698
+
699
+ try harness.runtime.dispatchPlatformEvent(app, .{ .gpu_surface_frame = .{
700
+ .label = font_app_canvas_label,
701
+ .size = geometry.SizeF.init(240, 200),
702
+ .scale_factor = 1,
703
+ .frame_index = 1,
704
+ .timestamp_ns = 1_000_000,
705
+ .nonblank = true,
706
+ } });
707
+ try std.testing.expect(app_state.installed);
708
+ try std.testing.expectEqual(@as(usize, 0), harness.runtime.dispatchErrors().len);
709
+ try std.testing.expectEqual(@as(usize, 1), harness.runtime.registeredCanvasFontCount());
710
+
711
+ // Per-glyph receipt: every ideograph resolves to its own real glyph
712
+ // in the registered face (the bundled face maps NONE of them — the
713
+ // exact gap the registration closes) and rasterizes with nonzero
714
+ // ink at body and headline sizes.
715
+ const face = harness.runtime.registeredCanvasFontFace(registered_font_id).?;
716
+ const InkCounter = struct {
717
+ covered: usize = 0,
718
+ pub fn pixel(self: *@This(), x: i32, y: i32, coverage: f32) void {
719
+ _ = x;
720
+ _ = y;
721
+ if (coverage > 0) self.covered += 1;
722
+ }
723
+ };
724
+ var seen_glyphs: [4]u16 = undefined;
725
+ var index: usize = 0;
726
+ var glyph_count: usize = 0;
727
+ while (index < cjk_receipt_text.len) : (glyph_count += 1) {
728
+ const len = try std.unicode.utf8ByteSequenceLength(cjk_receipt_text[index]);
729
+ const codepoint = try std.unicode.utf8Decode(cjk_receipt_text[index .. index + len]);
730
+ index += len;
731
+
732
+ try std.testing.expectEqual(@as(u16, 0), canvas.font_ttf.geist_regular.glyphIndex(codepoint));
733
+ const glyph = face.glyphIndex(codepoint);
734
+ try std.testing.expect(glyph != 0);
735
+ // cmap distinguishes the codepoints — four ideographs, four
736
+ // distinct glyphs, never one shared fallback shape.
737
+ for (seen_glyphs[0..glyph_count]) |seen| try std.testing.expect(seen != glyph);
738
+ seen_glyphs[glyph_count] = glyph;
739
+
740
+ for ([_]f32{ 16, 40 }) |size| {
741
+ const scale = size / face.units_per_em;
742
+ var builder = canvas.vector.PathBuilder(2048){};
743
+ try face.glyphOutline(glyph, .{ .a = scale, .b = 0, .c = 0, .d = -scale, .tx = 4, .ty = size }, &builder);
744
+ try std.testing.expect(builder.slice().len > 0);
745
+ var counter = InkCounter{};
746
+ try canvas.vector.fillPath(
747
+ builder.slice(),
748
+ canvas.Affine.identity(),
749
+ .nonzero,
750
+ canvas.vector.default_tolerance,
751
+ .{ .x0 = 0, .y0 = 0, .x1 = 64, .y1 = 64 },
752
+ &counter,
753
+ );
754
+ try std.testing.expect(counter.covered > 0);
755
+ }
756
+ }
757
+ try std.testing.expectEqual(@as(usize, 4), glyph_count);
758
+
759
+ // Layout measures the ideographs with the registered face's own
760
+ // advances, so measured line breaking agrees with the inked glyphs.
761
+ const provider = harness.runtime.textMeasureProvider().?;
762
+ try std.testing.expect(provider.measureWidth(registered_font_id, 16.0, cjk_receipt_text) > 0);
763
+
764
+ // End-to-end pixels through the deterministic reference renderer —
765
+ // the same path Windows and Linux present. The registered face
766
+ // draws the string as real outlines; the same view under the
767
+ // bundled face can only draw notdef boxes, so the two screenshots
768
+ // MUST differ. That difference is the receipt: the Chinese text on
769
+ // screen came from the registered face, not tofu.
770
+ const registered_shot = try fontFixtureScreenshot(harness, std.testing.allocator, registered_font_id);
771
+ defer std.testing.allocator.free(registered_shot);
772
+ const tofu_shot = try fontFixtureScreenshot(harness, std.testing.allocator, canvas.default_sans_font_id);
773
+ defer std.testing.allocator.free(tofu_shot);
774
+ var nonblank = false;
775
+ var pixel: usize = 0;
776
+ while (pixel + 4 <= registered_shot.len) : (pixel += 4) {
777
+ if (registered_shot[pixel + 3] != 0 and (registered_shot[pixel] != 0 or registered_shot[pixel + 1] != 0 or registered_shot[pixel + 2] != 0)) {
778
+ nonblank = true;
779
+ break;
780
+ }
781
+ }
782
+ try std.testing.expect(nonblank);
783
+ try std.testing.expect(!std.mem.eql(u8, registered_shot, tofu_shot));
784
+
785
+ // Self-calibrating tofu control: the bundled-face comparison above
786
+ // proves the pixels changed with the face, not that they are real
787
+ // ideographs — a renderer that wrongly resolved every ideograph to
788
+ // the REGISTERED face's notdef glyph and inked that glyph's own
789
+ // outline would still differ from the bundled shot (a different
790
+ // face's fallback pixels) and still pass nonblank. Render the same
791
+ // view with the same registered face showing a string the fixture
792
+ // face genuinely does not cover — first pinning that gap per
793
+ // codepoint — so the control shot IS this face's
794
+ // everything-uncovered rendering through the identical pipeline.
795
+ // Had the receipt string resolved to notdef, the two shots would
796
+ // match: same face, same per-glyph fallback, same advances.
797
+ // Differing proves the receipt pixels are real ideograph outlines,
798
+ // not any face's fallback.
799
+ var uncovered_index: usize = 0;
800
+ while (uncovered_index < cjk_uncovered_text.len) {
801
+ const len = try std.unicode.utf8ByteSequenceLength(cjk_uncovered_text[uncovered_index]);
802
+ const codepoint = try std.unicode.utf8Decode(cjk_uncovered_text[uncovered_index .. uncovered_index + len]);
803
+ uncovered_index += len;
804
+ try std.testing.expectEqual(@as(u16, 0), face.glyphIndex(codepoint));
805
+ }
806
+ try app_state.dispatch(&harness.runtime, 1, .show_uncovered_cjk);
807
+ const uncovered_shot = try fontFixtureScreenshot(harness, std.testing.allocator, registered_font_id);
808
+ defer std.testing.allocator.free(uncovered_shot);
809
+ try std.testing.expect(!std.mem.eql(u8, registered_shot, uncovered_shot));
810
+ }
811
+
812
+ // ------------------- late registration re-measures installed layouts
813
+
814
+ /// 你好 SDK — mixed CJK + Latin, chosen so the measured width MUST move
815
+ /// when the fixture face joins late. Pure-CJK width would not move: the
816
+ /// bundled estimator's East Asian wide fallback charges 1.0 em and the
817
+ /// fixture's ideographs really advance 1.0 em. The Latin tail is what
818
+ /// moves — the estimator charges Geist's own sub-em ASCII advances,
819
+ /// while the fixture face (subsetted to four ideographs plus notdef)
820
+ /// answers every ASCII codepoint with its 1.0 em notdef advance, the
821
+ /// documented no-cascade fallback registered faces take for uncovered
822
+ /// codepoints.
823
+ const late_mixed_text = "\u{4F60}\u{597D} SDK";
824
+
825
+ const late_window_label = "late-panel";
826
+ const late_window_canvas_label = "late-panel-canvas";
827
+
828
+ fn lateFontAppView(ui: *FontApp.Ui, model: *const FontAppModel) FontApp.Ui.Node {
829
+ _ = model;
830
+ // A row lays text out at its MEASURED intrinsic width (a column's
831
+ // default cross alignment stretches children to the column width),
832
+ // so this widget's frame is a direct function of what the
833
+ // measurement seam answers for the string.
834
+ return ui.row(.{ .gap = 8, .padding = 12 }, .{
835
+ ui.text(.{}, late_mixed_text),
836
+ });
837
+ }
838
+
839
+ fn lateFontAppWindows(model: *const FontAppModel, scratch: *FontApp.WindowsScratch) []const FontApp.WindowDescriptor {
840
+ _ = model;
841
+ scratch.windows[0] = .{
842
+ .label = late_window_label,
843
+ .canvas_label = late_window_canvas_label,
844
+ .title = "Late",
845
+ .width = 240,
846
+ .height = 200,
847
+ };
848
+ return scratch.windows[0..1];
849
+ }
850
+
851
+ fn lateFontAppWindowView(ui: *FontApp.Ui, model: *const FontAppModel, window_label: []const u8) FontApp.Ui.Node {
852
+ std.debug.assert(std.mem.eql(u8, window_label, late_window_label));
853
+ return lateFontAppView(ui, model);
854
+ }
855
+
856
+ /// The laid-out frame width of the view's one text widget.
857
+ fn lateTextFrameWidth(runtime: *core.Runtime, window_id: platform.WindowId, label: []const u8) !f32 {
858
+ const layout = try runtime.canvasWidgetLayout(window_id, label);
859
+ for (layout.nodes) |node| {
860
+ if (node.widget.kind == .text and std.mem.eql(u8, node.widget.text, late_mixed_text)) return node.widget.frame.width;
861
+ }
862
+ return error.TestUnexpectedResult;
863
+ }
864
+
865
+ test "a face registered after install re-measures every installed surface's layout" {
866
+ const harness = try TestHarness().create(std.testing.allocator, .{ .size = geometry.SizeF.init(240, 200) });
867
+ defer harness.destroy(std.testing.allocator);
868
+ harness.null_platform.gpu_surfaces = true;
869
+
870
+ // No declared fonts: the app installs measuring registered_font_id
871
+ // (the tokens' face slot) through the bundled estimator, the exact
872
+ // pre-registration state the fonts page's late-registration promise
873
+ // starts from. A declared secondary window pins the multi-surface
874
+ // half of the promise.
875
+ var options = fontAppOptions(&.{});
876
+ options.view = lateFontAppView;
877
+ options.windows_fn = lateFontAppWindows;
878
+ options.window_view = lateFontAppWindowView;
879
+ const app_state = try std.testing.allocator.create(FontApp);
880
+ defer std.testing.allocator.destroy(app_state);
881
+ app_state.* = FontApp.init(std.testing.allocator, .{}, options);
882
+ defer app_state.deinit();
883
+ const app = app_state.app();
884
+ try harness.start(app);
885
+
886
+ try harness.runtime.dispatchPlatformEvent(app, .{ .gpu_surface_frame = .{
887
+ .label = font_app_canvas_label,
888
+ .size = geometry.SizeF.init(240, 200),
889
+ .scale_factor = 1,
890
+ .frame_index = 1,
891
+ .timestamp_ns = 1_000_000,
892
+ .nonblank = true,
893
+ } });
894
+ try std.testing.expect(app_state.installed);
895
+
896
+ // The always-declared panel window opened during the installing
897
+ // rebuild's window reconcile; its own first frame installs its tree.
898
+ const panel_id = blk: {
899
+ var buffer: [platform.max_windows]platform.WindowInfo = undefined;
900
+ for (harness.runtime.listWindows(&buffer)) |info| {
901
+ if (std.mem.eql(u8, info.label, late_window_label)) break :blk info.id;
902
+ }
903
+ return error.TestUnexpectedResult;
904
+ };
905
+ try harness.runtime.dispatchPlatformEvent(app, .{ .gpu_surface_frame = .{
906
+ .window_id = panel_id,
907
+ .label = late_window_canvas_label,
908
+ .size = geometry.SizeF.init(240, 200),
909
+ .scale_factor = 1,
910
+ .frame_index = 1,
911
+ .timestamp_ns = 2_000_000,
912
+ .nonblank = true,
913
+ } });
914
+
915
+ const main_before = try lateTextFrameWidth(&harness.runtime, 1, font_app_canvas_label);
916
+ const panel_before = try lateTextFrameWidth(&harness.runtime, panel_id, late_window_canvas_label);
917
+ try std.testing.expectEqual(main_before, panel_before);
918
+
919
+ // Late registration through the runtime seam — the embedder path the
920
+ // fonts page documents under the `Options.fonts` sugar.
921
+ try harness.runtime.registerCanvasFont(registered_font_id, cjk_receipt_bytes);
922
+
923
+ // The registration requested a frame for every open surface; ONE
924
+ // arriving frame (the main canvas's here — arrival order is the
925
+ // platform's) must re-measure every installed surface, not just the
926
+ // surface whose frame landed.
927
+ try harness.runtime.dispatchPlatformEvent(app, .{ .gpu_surface_frame = .{
928
+ .label = font_app_canvas_label,
929
+ .size = geometry.SizeF.init(240, 200),
930
+ .scale_factor = 1,
931
+ .frame_index = 2,
932
+ .timestamp_ns = 3_000_000,
933
+ .nonblank = true,
934
+ } });
935
+ try std.testing.expectEqual(@as(usize, 0), harness.runtime.dispatchErrors().len);
936
+
937
+ const main_after = try lateTextFrameWidth(&harness.runtime, 1, font_app_canvas_label);
938
+ const panel_after = try lateTextFrameWidth(&harness.runtime, panel_id, late_window_canvas_label);
939
+ // Both surfaces now hold frames measured with the registered face's
940
+ // own advances — the widths moved, and moved identically.
941
+ try std.testing.expect(@abs(main_after - main_before) > 1);
942
+ try std.testing.expect(@abs(panel_after - panel_before) > 1);
943
+ try std.testing.expectEqual(main_after, panel_after);
944
+
945
+ // The re-measured width IS the face-aware seam's answer scaled into
946
+ // the frame, not merely a different guess: the face measures the
947
+ // string wider than the estimator did (1.0 em notdef per ASCII
948
+ // codepoint versus Geist's sub-em advances), so the frame grew.
949
+ try std.testing.expect(main_after > main_before);
950
+ }
951
+
952
+ // ------------------------ late registration adopts only on success
953
+
954
+ /// Model for the failed-rebuild retry test below: `row_count` extra rows
955
+ /// join the measured text, so the test can push one rebuild past the
956
+ /// per-view widget budget and then heal it.
957
+ const RetryFontModel = struct {
958
+ row_count: usize = 0,
959
+
960
+ pub fn rows(model: *const RetryFontModel, arena: std.mem.Allocator) []const usize {
961
+ const out = arena.alloc(usize, model.row_count) catch return &.{};
962
+ for (out, 0..) |*slot, index| slot.* = index;
963
+ return out;
964
+ }
965
+ };
966
+ const RetryFontMsg = union(enum) { noop };
967
+ const RetryFontApp = ui_app_model.UiApp(RetryFontModel, RetryFontMsg);
968
+
969
+ fn retryFontUpdate(model: *RetryFontModel, msg: RetryFontMsg) void {
970
+ _ = model;
971
+ _ = msg;
972
+ }
973
+
974
+ fn retryFontTokens(model: *const RetryFontModel) canvas.DesignTokens {
975
+ _ = model;
976
+ var tokens = canvas.DesignTokens{};
977
+ tokens.typography.font_id = registered_font_id;
978
+ return tokens;
979
+ }
980
+
981
+ fn retryRowKey(index: *const usize) canvas.UiKey {
982
+ return canvas.uiKey(@as(u64, index.*));
983
+ }
984
+
985
+ fn retryRow(ui: *RetryFontApp.Ui, index: *const usize) RetryFontApp.Ui.Node {
986
+ return ui.text(.{}, ui.fmt("Row {d}", .{index.*}));
987
+ }
988
+
989
+ fn retryFontView(ui: *RetryFontApp.Ui, model: *const RetryFontModel) RetryFontApp.Ui.Node {
990
+ // The measured text rides in a row (intrinsic width, like
991
+ // lateFontAppView above) so its frame moves when the registered
992
+ // face's advances replace the estimator's.
993
+ return ui.column(.{ .gap = 2 }, .{
994
+ ui.row(.{ .gap = 8, .padding = 12 }, .{ ui.text(.{}, late_mixed_text) }),
995
+ ui.each(model.rows(ui.arena), retryRowKey, retryRow),
996
+ });
997
+ }
998
+
999
+ test "a failed late-font rebuild leaves the count unadopted so the next healthy frame retries" {
1000
+ // The failing rebuild teaches through std.log; without lowering the
1001
+ // level the warning would fail the build runner's stderr check.
1002
+ const saved_log_level = std.testing.log_level;
1003
+ std.testing.log_level = .err;
1004
+ defer std.testing.log_level = saved_log_level;
1005
+
1006
+ const harness = try TestHarness().create(std.testing.allocator, .{ .size = geometry.SizeF.init(240, 200) });
1007
+ defer harness.destroy(std.testing.allocator);
1008
+ harness.null_platform.gpu_surfaces = true;
1009
+
1010
+ const app_state = try std.testing.allocator.create(RetryFontApp);
1011
+ defer std.testing.allocator.destroy(app_state);
1012
+ app_state.* = RetryFontApp.init(std.testing.allocator, .{}, .{
1013
+ .name = "ui-app-font-retry",
1014
+ .scene = font_app_scene,
1015
+ .canvas_label = font_app_canvas_label,
1016
+ .tokens_fn = retryFontTokens,
1017
+ .update = retryFontUpdate,
1018
+ .view = retryFontView,
1019
+ });
1020
+ defer app_state.deinit();
1021
+ const app = app_state.app();
1022
+ try harness.start(app);
1023
+
1024
+ try harness.runtime.dispatchPlatformEvent(app, .{ .gpu_surface_frame = .{
1025
+ .label = font_app_canvas_label,
1026
+ .size = geometry.SizeF.init(240, 200),
1027
+ .scale_factor = 1,
1028
+ .frame_index = 1,
1029
+ .timestamp_ns = 1_000_000,
1030
+ .nonblank = true,
1031
+ } });
1032
+ try std.testing.expect(app_state.installed);
1033
+ const width_before = try lateTextFrameWidth(&harness.runtime, 1, font_app_canvas_label);
1034
+
1035
+ // Production policy: dispatch degrades errors instead of dying —
1036
+ // the policy under which a rebuild that adopted the font count
1037
+ // BEFORE succeeding would strand stale layouts marked font-current,
1038
+ // never retried.
1039
+ harness.runtime.dispatch_error_policy = .degrade;
1040
+
1041
+ // Grow the model past the per-view widget budget (mutated directly
1042
+ // — no dispatch, so no rebuild yet), then register a face late so
1043
+ // the next frame's late-registration rebuild is the failing one.
1044
+ app_state.model.row_count = core.max_canvas_widget_nodes_per_view + 40;
1045
+ try harness.runtime.registerCanvasFont(registered_font_id, cjk_receipt_bytes);
1046
+ try harness.runtime.dispatchPlatformEvent(app, .{ .gpu_surface_frame = .{
1047
+ .label = font_app_canvas_label,
1048
+ .size = geometry.SizeF.init(240, 200),
1049
+ .scale_factor = 1,
1050
+ .frame_index = 2,
1051
+ .timestamp_ns = 2_000_000,
1052
+ .nonblank = true,
1053
+ } });
1054
+ try std.testing.expectEqual(@as(usize, 1), harness.runtime.dispatchErrors().len);
1055
+ // The failed rebuild must NOT adopt the count: the mismatch it
1056
+ // leaves behind is exactly what the next presented frame reads as
1057
+ // its retry trigger.
1058
+ try std.testing.expect(app_state.fonts_built_count != harness.runtime.registeredCanvasFontCount());
1059
+
1060
+ // Heal the model; the next presented frame observes the mismatch,
1061
+ // rebuilds every surface, and only then adopts.
1062
+ app_state.model.row_count = 0;
1063
+ try harness.runtime.dispatchPlatformEvent(app, .{ .gpu_surface_frame = .{
1064
+ .label = font_app_canvas_label,
1065
+ .size = geometry.SizeF.init(240, 200),
1066
+ .scale_factor = 1,
1067
+ .frame_index = 3,
1068
+ .timestamp_ns = 3_000_000,
1069
+ .nonblank = true,
1070
+ } });
1071
+ try std.testing.expectEqual(@as(usize, 1), harness.runtime.dispatchErrors().len);
1072
+ try std.testing.expectEqual(harness.runtime.registeredCanvasFontCount(), app_state.fonts_built_count);
1073
+
1074
+ // The retried rebuild re-measured with the registered face, not
1075
+ // merely repainted: the face answers the mixed string wider than
1076
+ // the estimator did (1.0 em notdef per ASCII codepoint), so the
1077
+ // text widget's frame grew.
1078
+ const width_after = try lateTextFrameWidth(&harness.runtime, 1, font_app_canvas_label);
1079
+ try std.testing.expect(width_after > width_before);
1080
+ }
1081
+
1082
+ test "ui app fonts option surfaces the glyph-budget refusal as a teaching error" {
1083
+ const harness = try TestHarness().create(std.testing.allocator, .{ .size = geometry.SizeF.init(240, 200) });
1084
+ defer harness.destroy(std.testing.allocator);
1085
+ harness.null_platform.gpu_surfaces = true;
1086
+
1087
+ const patched = try overBudgetFontBytes(std.testing.allocator);
1088
+ defer std.testing.allocator.free(patched);
1089
+
1090
+ const fonts = [_]FontApp.FontRegistration{.{
1091
+ .id = registered_font_id,
1092
+ .name = "TooDense.ttf",
1093
+ .ttf = patched,
1094
+ }};
1095
+ const app_state = try std.testing.allocator.create(FontApp);
1096
+ defer std.testing.allocator.destroy(app_state);
1097
+ app_state.* = FontApp.init(std.testing.allocator, .{}, fontAppOptions(&fonts));
1098
+ defer app_state.deinit();
1099
+ const app = app_state.app();
1100
+ try harness.start(app);
1101
+ harness.runtime.dispatch_error_policy = .degrade;
1102
+
1103
+ // The installing frame surfaces the refusal through the dispatch
1104
+ // error channel (the warn log names the face's declared maxima
1105
+ // against the budgets); nothing registers, the app stays alive.
1106
+ try harness.runtime.dispatchPlatformEvent(app, .{ .gpu_surface_frame = .{
1107
+ .label = font_app_canvas_label,
1108
+ .size = geometry.SizeF.init(240, 200),
1109
+ .scale_factor = 1,
1110
+ .frame_index = 1,
1111
+ .timestamp_ns = 1_000_000,
1112
+ .nonblank = true,
1113
+ } });
1114
+ try std.testing.expectEqual(@as(usize, 0), harness.runtime.registeredCanvasFontCount());
1115
+ try std.testing.expect(harness.runtime.dispatchErrorTotal() > 0);
1116
+ }