font/sprite+renderer: never constrain sprite glyphs

This was creating problems with the branch drawing glyphs at some sizes.

In the future the whole "foreground modes" thing needs to be reworked,
so this is just a stopgap until that gets turned in to something nicer.
This commit is contained in:
Qwerasd
2025-06-29 21:32:22 -06:00
parent e691404a57
commit 2084d5f256
3 changed files with 21 additions and 10 deletions

View File

@@ -20,3 +20,6 @@ atlas_y: u32,
/// horizontal position to increase drawing position for strings /// horizontal position to increase drawing position for strings
advance_x: f32, advance_x: f32,
/// Whether we drew this glyph ourselves with the sprite font.
sprite: bool = false,

View File

@@ -216,7 +216,7 @@ pub fn renderGlyph(
// Write the drawing to the atlas // Write the drawing to the atlas
const region = try canvas.writeAtlas(alloc, atlas); const region = try canvas.writeAtlas(alloc, atlas);
return font.Glyph{ return .{
.width = region.width, .width = region.width,
.height = region.height, .height = region.height,
.offset_x = @as(i32, @intCast(canvas.clip_left)) - @as(i32, @intCast(padding_x)), .offset_x = @as(i32, @intCast(canvas.clip_left)) - @as(i32, @intCast(padding_x)),
@@ -224,6 +224,7 @@ pub fn renderGlyph(
.atlas_x = region.x, .atlas_x = region.x,
.atlas_y = region.y, .atlas_y = region.y,
.advance_x = @floatFromInt(width), .advance_x = @floatFromInt(width),
.sprite = true,
}; };
} }

View File

@@ -3039,15 +3039,22 @@ pub fn Renderer(comptime GraphicsAPI: type) type {
return; return;
} }
const mode: shaderpkg.CellText.Mode = switch (fgMode( // We always use fg mode for sprite glyphs, since we know we never
render.presentation, // need to constrain them, and we don't have any color sprites.
cell_pin, //
)) { // Otherwise we defer to `fgMode`.
.normal => .fg, const mode: shaderpkg.CellText.Mode =
.color => .fg_color, if (render.glyph.sprite)
.constrained => .fg_constrained, .fg
.powerline => .fg_powerline, else switch (fgMode(
}; render.presentation,
cell_pin,
)) {
.normal => .fg,
.color => .fg_color,
.constrained => .fg_constrained,
.powerline => .fg_powerline,
};
try self.cells.add(self.alloc, .text, .{ try self.cells.add(self.alloc, .text, .{
.mode = mode, .mode = mode,