summaryrefslogtreecommitdiff
path: root/src/fonts.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-10 02:05:00 -0300
committerGabriel Schneider <[email protected]>2026-11-10 02:09:16 -0300
commit7a443bcdd4d82b259f6a02ade335aa5ccadf2640 (patch)
tree4f6b9a4f29b3638d547b78aaa3f31b33201fe421 /src/fonts.zig
parente6ea52e36cbb7c557681e6c7a55fa6f0d92f8754 (diff)
downloadpardes-7a443bcdd4d82b259f6a02ade335aa5ccadf2640.tar.gz
pardes-7a443bcdd4d82b259f6a02ade335aa5ccadf2640.zip
macos: a window client draws its own motions and follows the session: its loop wakes a frame at a time while its glide, caret or trail moves (frontendMoving, also its FrameStats' animating) and at each blink edge, a touchpad's fraction is its picture with whole rows posted as inputs (stepScroll's body is scrollRows, the local pump's and the client's), and the session's Font is resolved here by the face's name (fonts.remote, syncReplicaFont), where before the client kept its own font and scrolled a whole row a turn
Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge
Diffstat (limited to 'src/fonts.zig')
-rw-r--r--src/fonts.zig28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/fonts.zig b/src/fonts.zig
index 48fa7179..84ce5307 100644
--- a/src/fonts.zig
+++ b/src/fonts.zig
@@ -76,6 +76,20 @@ pub fn list(arena: std.mem.Allocator, want_name: ?[]const u8) []const Font {
return scan(arena, null, true);
}
+/// A remote config's absolute font path belongs to its machine. Resolve the
+/// same face by name on this machine, retaining the filename as a fallback.
+pub fn remote(arena: std.mem.Allocator, path: []const u8, name: []const u8) ?Font {
+ if (name.len > 0) {
+ const matches = list(arena, name);
+ if (matches.len > 0) return matches[0];
+ }
+ const base = std.Io.Dir.path.basename(path);
+ const stem = base[0 .. base.len - std.Io.Dir.path.extension(base).len];
+ if (stem.len == 0 or std.mem.eql(u8, stem, name)) return null;
+ const matches = list(arena, stem);
+ return if (matches.len > 0) matches[0] else null;
+}
+
/// Installed members of `fallback_names`, returned in preference order. This
/// is runtime discovery only: no local font path or exploration result enters
/// the build, and a machine with none simply uses embedded Adwaita Mono.
@@ -406,3 +420,17 @@ test "the walk finds this machine's monospace faces" {
try std.testing.expect(std.mem.endsWith(u8, menlo.path, ".ttc"));
}
}
+
+test "a remote font config resolves the installed face despite another machine's path" {
+ var arena: std.heap.ArenaAllocator = .init(std.testing.allocator);
+ defer arena.deinit();
+ const alloc = arena.allocator();
+ const installed = list(alloc, null);
+ if (installed.len == 0) return error.SkipZigTest;
+ const face = installed[0];
+ const foreign = try std.fmt.allocPrint(alloc, "/other-machine/fonts/{s}", .{std.Io.Dir.path.basename(face.path)});
+ const by_name = remote(alloc, foreign, face.name) orelse return error.MissingLocalFace;
+ try std.testing.expectEqualStrings(face.path, by_name.path);
+ const by_file = remote(alloc, foreign, "") orelse return error.MissingLocalFace;
+ try std.testing.expectEqualStrings(face.path, by_file.path);
+}