From 329697779a662792d9e88c387044ef2b9c12a82f Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Fri, 5 Apr 2024 18:51:26 -0700 Subject: [PATCH] renderer/metal: convert more --- src/font/shaper/coretext.zig | 5 +++-- src/font/shaper/run.zig | 20 ++++++++++---------- src/renderer/Metal.zig | 2 +- 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/src/font/shaper/coretext.zig b/src/font/shaper/coretext.zig index d3d57f7b1..56e172aa3 100644 --- a/src/font/shaper/coretext.zig +++ b/src/font/shaper/coretext.zig @@ -9,6 +9,7 @@ const DeferredFace = font.DeferredFace; const Group = font.Group; const GroupCache = font.GroupCache; const Library = font.Library; +const SharedGrid = font.SharedGrid; const Style = font.Style; const Presentation = font.Presentation; const terminal = @import("../../terminal/main.zig"); @@ -189,7 +190,7 @@ pub const Shaper = struct { pub fn runIterator( self: *Shaper, - group: *GroupCache, + grid: *SharedGrid, screen: *const terminal.Screen, row: terminal.Pin, selection: ?terminal.Selection, @@ -197,7 +198,7 @@ pub const Shaper = struct { ) font.shape.RunIterator { return .{ .hooks = .{ .shaper = self }, - .group = group, + .grid = grid, .screen = screen, .row = row, .selection = selection, diff --git a/src/font/shaper/run.zig b/src/font/shaper/run.zig index b5c29ec3f..2d982411f 100644 --- a/src/font/shaper/run.zig +++ b/src/font/shaper/run.zig @@ -15,17 +15,17 @@ pub const TextRun = struct { /// The total number of cells produced by this run. cells: u16, - /// The font group that built this run. - group: *font.GroupCache, + /// The font grid that built this run. + grid: *font.SharedGrid, /// The font index to use for the glyphs of this run. - font_index: font.Group.FontIndex, + font_index: font.Collection.Index, }; /// RunIterator is an iterator that yields text runs. pub const RunIterator = struct { hooks: font.Shaper.RunIteratorHook, - group: *font.GroupCache, + grid: *font.SharedGrid, screen: *const terminal.Screen, row: terminal.Pin, selection: ?terminal.Selection = null, @@ -49,7 +49,7 @@ pub const RunIterator = struct { if (self.i >= max) return null; // Track the font for our current run - var current_font: font.Group.FontIndex = .{}; + var current_font: font.Collection.Index = .{}; // Allow the hook to prepare try self.hooks.prepare(); @@ -117,7 +117,7 @@ pub const RunIterator = struct { } else emoji: { // If we're not a grapheme, our individual char could be // an emoji so we want to check if we expect emoji presentation. - // The font group indexForCodepoint we use below will do this + // The font grid indexForCodepoint we use below will do this // automatically. break :emoji null; }; @@ -160,7 +160,7 @@ pub const RunIterator = struct { // grapheme, i.e. combining characters), we need to find a font // that supports all of them. const font_info: struct { - idx: font.Group.FontIndex, + idx: font.Collection.Index, fallback: ?u32 = null, } = font_info: { // If we find a font that supports this entire grapheme @@ -231,7 +231,7 @@ pub const RunIterator = struct { return TextRun{ .offset = @intCast(self.i), .cells = @intCast(j - self.i), - .group = self.group, + .grid = self.grid, .font_index = current_font, }; } @@ -248,7 +248,7 @@ pub const RunIterator = struct { cell: *terminal.Cell, style: font.Style, presentation: ?font.Presentation, - ) !?font.Group.FontIndex { + ) !?font.Collection.Index { // Get the font index for the primary codepoint. const primary_cp: u32 = if (cell.isEmpty() or cell.codepoint() == 0) ' ' else cell.codepoint(); const primary = try self.group.indexForCodepoint( @@ -265,7 +265,7 @@ pub const RunIterator = struct { // If this is a grapheme, we need to find a font that supports // all of the codepoints in the grapheme. const cps = self.row.grapheme(cell) orelse return primary; - var candidates = try std.ArrayList(font.Group.FontIndex).initCapacity(alloc, cps.len + 1); + var candidates = try std.ArrayList(font.Collection.Index).initCapacity(alloc, cps.len + 1); defer candidates.deinit(); candidates.appendAssumeCapacity(primary); diff --git a/src/renderer/Metal.zig b/src/renderer/Metal.zig index 4abb4c0fd..f5db7471c 100644 --- a/src/renderer/Metal.zig +++ b/src/renderer/Metal.zig @@ -1649,7 +1649,7 @@ fn rebuildCells( // Split our row into runs and shape each one. var iter = self.font_shaper.runIterator( - self.font_group, + self.font_grid, screen, row, row_selection,