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.
This commit is contained in:
Qwerasd
2024-09-23 18:35:20 -06:00
parent bf2794f90f
commit ecb3c543b3

View File

@ -1808,19 +1808,25 @@ fn updateCell(
}); });
} }
// If the cell has a character, draw it // If the shaper cell has a glyph, draw it.
if (cell.hasText()) fg: { if (shaper_cell.glyph_index) |glyph_index| glyph: {
// Render // Render
const render = try self.font_grid.renderGlyph( const render = try self.font_grid.renderGlyph(
self.alloc, self.alloc,
shaper_run.font_index, shaper_run.font_index,
shaper_cell.glyph_index orelse break :fg, glyph_index,
.{ .{
.grid_metrics = self.grid_metrics, .grid_metrics = self.grid_metrics,
.thicken = self.config.font_thicken, .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 // If we're rendering a color font, we use the color atlas
const mode: CellProgram.CellMode = switch (try fgMode( const mode: CellProgram.CellMode = switch (try fgMode(
render.presentation, render.presentation,