From 3b3c93af0272fa1989ca850e6b8e6c61735f92fd Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Thu, 24 Nov 2022 10:05:25 -0800 Subject: [PATCH] metal: support for box glyphs --- src/renderer/Metal.zig | 13 +++++++++++-- src/renderer/OpenGL.zig | 2 +- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/renderer/Metal.zig b/src/renderer/Metal.zig index 0868218db..0112b0926 100644 --- a/src/renderer/Metal.zig +++ b/src/renderer/Metal.zig @@ -408,6 +408,12 @@ pub fn setFontSize(self: *Metal, size: font.face.DesiredSize) !void { if (std.meta.eql(self.cell_size, new_cell_size)) return; self.cell_size = new_cell_size; + // Set the cell size of the box font + if (self.font_group.group.box_font) |*box| { + box.width = @floatToInt(u32, self.cell_size.width); + box.height = @floatToInt(u32, self.cell_size.height); + } + // Notify the window that the cell size changed. _ = self.window_mailbox.push(.{ .cell_size = new_cell_size, @@ -880,8 +886,11 @@ pub fn updateCell( ); // If we're rendering a color font, we use the color atlas - const face = try self.font_group.group.faceFromIndex(shaper_run.font_index); - const mode: GPUCellMode = if (face.presentation == .emoji) .fg_color else .fg; + const presentation = try self.font_group.group.presentationFromIndex(shaper_run.font_index); + const mode: GPUCellMode = switch (presentation) { + .text => .fg, + .emoji => .fg_color, + }; self.cells.appendAssumeCapacity(.{ .mode = mode, diff --git a/src/renderer/OpenGL.zig b/src/renderer/OpenGL.zig index d8ee2fa89..bc40d5207 100644 --- a/src/renderer/OpenGL.zig +++ b/src/renderer/OpenGL.zig @@ -967,7 +967,7 @@ pub fn updateCell( // If we're rendering a color font, we use the color atlas const presentation = try self.font_group.group.presentationFromIndex(shaper_run.font_index); - var mode: GPUCellMode = switch (presentation) { + const mode: GPUCellMode = switch (presentation) { .text => .fg, .emoji => .fg_color, };