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.pull/7732/head
parent
e691404a57
commit
2084d5f256
|
|
@ -20,3 +20,6 @@ atlas_y: u32,
|
|||
|
||||
/// horizontal position to increase drawing position for strings
|
||||
advance_x: f32,
|
||||
|
||||
/// Whether we drew this glyph ourselves with the sprite font.
|
||||
sprite: bool = false,
|
||||
|
|
|
|||
|
|
@ -216,7 +216,7 @@ pub fn renderGlyph(
|
|||
// Write the drawing to the atlas
|
||||
const region = try canvas.writeAtlas(alloc, atlas);
|
||||
|
||||
return font.Glyph{
|
||||
return .{
|
||||
.width = region.width,
|
||||
.height = region.height,
|
||||
.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_y = region.y,
|
||||
.advance_x = @floatFromInt(width),
|
||||
.sprite = true,
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3039,15 +3039,22 @@ pub fn Renderer(comptime GraphicsAPI: type) type {
|
|||
return;
|
||||
}
|
||||
|
||||
const mode: shaderpkg.CellText.Mode = switch (fgMode(
|
||||
render.presentation,
|
||||
cell_pin,
|
||||
)) {
|
||||
.normal => .fg,
|
||||
.color => .fg_color,
|
||||
.constrained => .fg_constrained,
|
||||
.powerline => .fg_powerline,
|
||||
};
|
||||
// We always use fg mode for sprite glyphs, since we know we never
|
||||
// need to constrain them, and we don't have any color sprites.
|
||||
//
|
||||
// Otherwise we defer to `fgMode`.
|
||||
const mode: shaderpkg.CellText.Mode =
|
||||
if (render.glyph.sprite)
|
||||
.fg
|
||||
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, .{
|
||||
.mode = mode,
|
||||
|
|
|
|||
Loading…
Reference in New Issue