diff options
| author | Can Celik <ogulcancelik@gmail.com> | 2026-09-10 21:51:57 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-09-10 21:51:57 +0300 |
| commit | 425c86179791cd32e2d4ce0ae7f269940b4b0663 (patch) | |
| tree | e52c4383a6d69216cbe2a32638bf90841d7e2189 /vendor/libghostty-vt/src/font/SharedGridSet.zig | |
| parent | 90e947a6e26e02f10ec7f1694c4eb5b78a86406b (diff) | |
chore: upgrade libghostty and preserve terminal behavior (#3906)
Diffstat (limited to 'vendor/libghostty-vt/src/font/SharedGridSet.zig')
| -rw-r--r-- | vendor/libghostty-vt/src/font/SharedGridSet.zig | 33 |
1 files changed, 26 insertions, 7 deletions
diff --git a/vendor/libghostty-vt/src/font/SharedGridSet.zig b/vendor/libghostty-vt/src/font/SharedGridSet.zig index 9d8148bd..dc7d8dd7 100644 --- a/vendor/libghostty-vt/src/font/SharedGridSet.zig +++ b/vendor/libghostty-vt/src/font/SharedGridSet.zig @@ -28,6 +28,7 @@ const SharedGrid = font.SharedGrid; const discovery = @import("discovery.zig"); const configpkg = @import("../config.zig"); const Config = configpkg.Config; +const global = @import("../global.zig"); const log = std.log.scoped(.font_shared_grid_set); @@ -44,7 +45,7 @@ font_lib: Library, font_discover: ?Discover = null, /// Lock to protect multi-threaded access to the map. -lock: std.Thread.Mutex = .{}, +lock: std.Io.Mutex = .init, pub const InitError = Library.InitError; @@ -79,8 +80,8 @@ pub fn deinit(self: *SharedGridSet) void { /// Returns the number of cached grids. pub fn count(self: *SharedGridSet) usize { - self.lock.lock(); - defer self.lock.unlock(); + self.lock.lockUncancelable(global.io()); + defer self.lock.unlock(global.io()); return self.map.count(); } @@ -100,8 +101,8 @@ pub fn ref( var key = try Key.init(self.alloc, config, font_size); errdefer key.deinit(); - self.lock.lock(); - defer self.lock.unlock(); + self.lock.lockUncancelable(global.io()); + defer self.lock.unlock(global.io()); const gop = try self.map.getOrPut(self.alloc, key); if (gop.found_existing) { @@ -339,6 +340,24 @@ fn collection( // specifying a font-family for emoji. if (comptime builtin.target.os.tag.isDarwin() and Discover != void) apple_emoji: { const disco = try self.discover() orelse break :apple_emoji; + + // Fast path: we know the exact name of the font we want so we + // can look it up directly, which is sometimes significantly faster than + // full discovery (e.g. CoreText). + if (@hasDecl(Discover, "discoverExactFamily")) { + if (try disco.discoverExactFamily( + "Apple Color Emoji", + )) |face| { + _ = try c.addDeferred(self.alloc, face, .{ + .style = .regular, + .fallback = true, + // No size adjustment for emojis. + .size_adjustment = .none, + }); + break :apple_emoji; + } + } + var disco_it = try disco.discover(self.alloc, .{ .family = "Apple Color Emoji", }); @@ -392,8 +411,8 @@ fn collection( /// Decrement the ref count for the given key. If the ref count is zero, /// the grid will be deinitialized and removed from the map.j:w pub fn deref(self: *SharedGridSet, key: Key) void { - self.lock.lock(); - defer self.lock.unlock(); + self.lock.lockUncancelable(global.io()); + defer self.lock.unlock(global.io()); const entry = self.map.getEntry(key) orelse return; assert(entry.value_ptr.ref >= 1); |
