From 9fa0a88e43f9fa2b548acd9336935cc96c6ea3e3 Mon Sep 17 00:00:00 2001 From: Peterino2 Date: Tue, 22 Sep 2026 12:27:51 -0700 Subject: [PATCH] saving --- include/uhdk.h | 5 ++-- src/api/session.zig | 1 - src/api/windows.zig | 31 +++++++++++---------- src/linux/font/README.md | 2 ++ src/linux/tools/bitmap-font.py | 51 +++++++++++----------------------- 5 files changed, 37 insertions(+), 53 deletions(-) diff --git a/include/uhdk.h b/include/uhdk.h index 87ed527..cd0352b 100644 --- a/include/uhdk.h +++ b/include/uhdk.h @@ -459,8 +459,9 @@ UHDK_API const uhdk_gl_functions *UHDK_CALL uhdk_get_gl(uhdk_session *session); UHDK_API uhdk_window *UHDK_CALL uhdk_get_window(uhdk_session *session); -/* NULL safe. Discards an unfinished frame without presenting. Destroy app-owned - * GL resources before close; all session handles become invalid on return. */ +/* NULL safe. Valid after the session stops or enters a terminal error state, and + * discards an unfinished frame without presenting. Destroy app-owned GL resources + * before close; all session handles become invalid on return. */ UHDK_API void UHDK_CALL uhdk_close(uhdk_session *session); /* Synchronously create an additional native window for an external renderer. diff --git a/src/api/session.zig b/src/api/session.zig index 68e5b73..beb5bb9 100644 --- a/src/api/session.zig +++ b/src/api/session.zig @@ -245,7 +245,6 @@ pub export fn uhdk_get_window(session: ?*c.uhdk_session) ?*c.uhdk_window { pub export fn uhdk_close(session: ?*c.uhdk_session) void { const a = state(session orelse return); - std.debug.assert(runtime.validateMainThreadSessionReady(a) == abi.OK); _ = release(a); app.destroy(handle(a)); } diff --git a/src/api/windows.zig b/src/api/windows.zig index 0200195..adbcd3d 100644 --- a/src/api/windows.zig +++ b/src/api/windows.zig @@ -13,21 +13,22 @@ pub fn queueCreate( if (out == null) return abi.INVALID; const d = desc.*; - if (!validStyle(&d.style) - or !abi.validText(d.title, true) - or !abi.finiteSize(d.content_size) - or d.content_size.width == 0 - or d.content_size.height == 0 - or !abi.finiteSize(d.min_size) - or !abi.finiteSize(d.max_size) - or d.flags & ~@as(u32, c.Z_WINDOW_OPENGL) != 0) return abi.INVALID; - if ((d.max_size.width != 0 - and d.max_size.width < d.min_size.width) - or (d.max_size.height != 0 - and d.max_size.height < d.min_size.height)) return abi.INVALID; - if (d.parent != null - and (runtime.fromObjectHandle(d.parent).app != runtime.fromAppHandle(handle) - or !runtime.fromObjectHandle(d.parent).alive)) return abi.INVALID; + + if (d.content_size.width == 0 or d.content_size.height == 0) + return abi.INVALID; + + if (!abi.finiteSize(d.content_size) or !abi.finiteSize(d.content_size) or !abi.finiteSize(d.min_size) or !abi.finiteSize(d.max_size)) + return abi.INVALID; + + if (!validStyle(&d.style) or d.content_size.width == 0 or d.content_size.height == 0 or d.flags & ~@as(u32, c.Z_WINDOW_OPENGL) != 0) + return abi.INVALID; + + if ((d.max_size.width != 0 and d.max_size.width < d.min_size.width) or (d.max_size.height != 0 and d.max_size.height < d.min_size.height)) + return abi.INVALID; + + if (d.parent != null and (runtime.fromObjectHandle(d.parent).app != runtime.fromAppHandle(handle) or !runtime.fromObjectHandle(d.parent).alive)) + return abi.INVALID; + const command = runtime.createAppCommand(handle, c.Z_WINDOW) catch |err| return runtime.applicationError(err); const object = runtime.createObject(runtime.fromAppHandle(handle), c.Z_KIND_WINDOW) catch { runtime.abandon(command); diff --git a/src/linux/font/README.md b/src/linux/font/README.md index c4dfb89..d966e41 100644 --- a/src/linux/font/README.md +++ b/src/linux/font/README.md @@ -14,6 +14,8 @@ The source is the unmodified Google Fonts Roboto variable TTF, pinned in `manifest.json`, with weight 400 and width 100. The generated bitmap is a font derivative distributed under the accompanying SIL Open Font License (`OFL.txt`). The TTF is downloaded only for maintainer regeneration and is not shipped here. +The Python generator rasterizes the TTF and writes the packed `.fontatlas` +directly, with no intermediate file format or separate packing tool. Binary format, little-endian: `FAP1`, u16 glyph count, u16 fallback glyph index, then sorted 12-byte records (u16 codepoint, u16 absolute data offset, u16 data diff --git a/src/linux/tools/bitmap-font.py b/src/linux/tools/bitmap-font.py index 348354c..6e75a5c 100644 --- a/src/linux/tools/bitmap-font.py +++ b/src/linux/tools/bitmap-font.py @@ -33,9 +33,9 @@ def generate(manifest, font_path): axes = font.get_variation_axes() font.set_variation_by_axes([400 if a['name'] == b'Weight' else 100 if a['name'] == b'Width' else a['default'] for a in axes]) codepoints = list(range(32, 127)) - header_size = 8 + len(codepoints) * 16 - records, pixels = bytearray(), bytearray() - for cp in codepoints: + records = bytearray(12 * len(codepoints)) + streams = bytearray() + for index, cp in enumerate(codepoints): character = chr(cp) x, y, right, bottom = font.getbbox(character, anchor='ls') width, height = right - x, bottom - y @@ -43,9 +43,18 @@ def generate(manifest, font_path): if width and height: ImageDraw.Draw(image).text((-x, -y), character, font=font, fill=255, anchor='ls') advance = int(font.getlength(character) + .5) - records += struct.pack('