From ecb3c543b39a848fa58cce0780e5e73400f993d3 Mon Sep 17 00:00:00 2001 From: Qwerasd Date: Mon, 23 Sep 2024 18:35:20 -0600 Subject: [PATCH] renderer/OpenGL: use better logic for whether to render glyph Metal already had this change made, so I copied it over from there. This logic is more straightforward. Also copied the check to skip 0-sized glyphs, since sometimes, for example, spaces are emitted as glyphs by the shaper for some reason, even though they have no actual content, and we want to avoid sending a bunch of useless stuff to the GPU. --- src/renderer/OpenGL.zig | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/renderer/OpenGL.zig b/src/renderer/OpenGL.zig index 082f330c5..760721af3 100644 --- a/src/renderer/OpenGL.zig +++ b/src/renderer/OpenGL.zig @@ -1808,19 +1808,25 @@ fn updateCell( }); } - // If the cell has a character, draw it - if (cell.hasText()) fg: { + // If the shaper cell has a glyph, draw it. + if (shaper_cell.glyph_index) |glyph_index| glyph: { // Render const render = try self.font_grid.renderGlyph( self.alloc, shaper_run.font_index, - shaper_cell.glyph_index orelse break :fg, + glyph_index, .{ .grid_metrics = self.grid_metrics, .thicken = self.config.font_thicken, }, ); + // If the glyph is 0 width or height, it will be invisible + // when drawn, so don't bother adding it to the buffer. + if (render.glyph.width == 0 or render.glyph.height == 0) { + break :glyph; + } + // If we're rendering a color font, we use the color atlas const mode: CellProgram.CellMode = switch (try fgMode( render.presentation,