metal: support for box glyphs

This commit is contained in:
Mitchell Hashimoto
2022-11-24 10:05:25 -08:00
parent fc8f36a59e
commit 3b3c93af02
2 changed files with 12 additions and 3 deletions

View File

@ -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; if (std.meta.eql(self.cell_size, new_cell_size)) return;
self.cell_size = new_cell_size; 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. // Notify the window that the cell size changed.
_ = self.window_mailbox.push(.{ _ = self.window_mailbox.push(.{
.cell_size = new_cell_size, .cell_size = new_cell_size,
@ -880,8 +886,11 @@ pub fn updateCell(
); );
// If we're rendering a color font, we use the color atlas // 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 presentation = try self.font_group.group.presentationFromIndex(shaper_run.font_index);
const mode: GPUCellMode = if (face.presentation == .emoji) .fg_color else .fg; const mode: GPUCellMode = switch (presentation) {
.text => .fg,
.emoji => .fg_color,
};
self.cells.appendAssumeCapacity(.{ self.cells.appendAssumeCapacity(.{
.mode = mode, .mode = mode,

View File

@ -967,7 +967,7 @@ pub fn updateCell(
// If we're rendering a color font, we use the color atlas // If we're rendering a color font, we use the color atlas
const presentation = try self.font_group.group.presentationFromIndex(shaper_run.font_index); const presentation = try self.font_group.group.presentationFromIndex(shaper_run.font_index);
var mode: GPUCellMode = switch (presentation) { const mode: GPUCellMode = switch (presentation) {
.text => .fg, .text => .fg,
.emoji => .fg_color, .emoji => .fg_color,
}; };