diff options
Diffstat (limited to 'core/exec.zig')
| -rw-r--r-- | core/exec.zig | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/core/exec.zig b/core/exec.zig index 5a9bf192..3f3b16a7 100644 --- a/core/exec.zig +++ b/core/exec.zig @@ -864,6 +864,14 @@ pub const acme_words = [_]struct { acme: []const u8, pardes: ?[]const u8, hint: .{ .acme = "Abort", .pardes = null, .hint = ": a debugging word that crashes acme" }, }; +/// The first of this machine's fonts named `name`, as its path, a NUL and +/// its name; empty for none. +fn fontNamed(arena: std.mem.Allocator, name: []const u8) []const u8 { + const matches = fonts.list(arena, name); + if (matches.len == 0) return ""; + return std.fmt.allocPrint(arena, "{s}\x00{s}", .{ matches[0].path, matches[0].name }) catch ""; +} + pub fn executeBuiltinLine(p: *Pardes, id: usize, txt: []const u8) bool { const raw = commandText(txt); if (raw.len == 0 or p.exec_depth >= max_exec_depth) return false; @@ -1008,9 +1016,11 @@ pub fn applySettingBuiltin(p: *Pardes, setting: config.Runtime.Setting, arg: ?[] .font => { if (comptime !font_picker) return; const spec = config.Runtime.FontSpec.parse(arg orelse return) orelse return; - const matches = fonts.list(p.scratch.allocator(), spec.name); - if (matches.len == 0) return; - if (!p.settings.requestFont(matches[0].path, matches[0].name, spec.size_hundredths)) return; + // The session's machine's fonts, a question to its disk: a + // client's replay takes the session's answer, never its own. + const found = pardes.tape.site(.fonts, p.scratch.allocator(), fontNamed, .{ p.scratch.allocator(), spec.name }); + const nul = std.mem.indexOfScalar(u8, found, 0) orelse return; + if (!p.settings.requestFont(found[0..nul], found[nul + 1 ..], spec.size_hundredths)) return; p.font_request_taken = false; }, // A shell that is no executable is refused, not taken and quietly |
