render text to correct place

this should probably be fixed somewhere in the font
metrics but i am not sure how
This commit is contained in:
Gabriel Dinner-David
2024-11-22 17:40:57 -05:00
parent 7640e459e7
commit 133520e067
2 changed files with 16 additions and 14 deletions

View File

@ -42,19 +42,21 @@ fn run_(str: []const u8) !void {
try surface.init(alloc, &config, app, &app_runtime, apprt_surface); try surface.init(alloc, &config, app, &app_runtime, apprt_surface);
std.log.err("{}", .{surface.size}); std.log.err("{}", .{surface.size});
try surface.renderer.setScreenSize(surface.size); try surface.renderer.setScreenSize(surface.size);
try surface.renderer_state.terminal.printString("M_yhelloaaaaaaaaa\n🐏\n👍🏽\nM_ghostty"); const esc = "\x1b[";
surface.renderer_state.terminal.setCursorPos(4, 2); surface.io.processOutput("M_yhelloaaaaaaaaa\n\r🐏\n\r👍🏽\n\rM_ghostty" ++ esc ++ "2;2H" ++ esc ++ "48;2;240;40;40m" ++ esc ++ "38;2;23;255;80mhello");
try surface.renderer_state.terminal.setAttribute(.{ .direct_color_bg = .{ // try surface.renderer_state.terminal.printString("M_yhelloaaaaaaaaa\n🐏\n👍🏽\nM_ghostty");
.r = 240, // surface.renderer_state.terminal.setCursorPos(4, 2);
.g = 40, // try surface.renderer_state.terminal.setAttribute(.{ .direct_color_bg = .{
.b = 40, // .r = 240,
} }); // .g = 40,
try surface.renderer_state.terminal.setAttribute(.{ .direct_color_fg = .{ // .b = 40,
.r = 255, // } });
.g = 255, // try surface.renderer_state.terminal.setAttribute(.{ .direct_color_fg = .{
.b = 255, // .r = 255,
} }); // .g = 255,
try surface.renderer_state.terminal.printString("hello"); // .b = 255,
// } });
// try surface.renderer_state.terminal.printString("hello");
try surface.renderer.updateFrame(apprt_surface, &surface.renderer_state, false); try surface.renderer.updateFrame(apprt_surface, &surface.renderer_state, false);
try surface.renderer.drawFrame(apprt_surface); try surface.renderer.drawFrame(apprt_surface);
try surface.renderer.updateFrame(apprt_surface, &surface.renderer_state, false); try surface.renderer.updateFrame(apprt_surface, &surface.renderer_state, false);

View File

@ -205,7 +205,7 @@ void main() {
// The glyph_offset.y is the y bearing, a y value that when added // The glyph_offset.y is the y bearing, a y value that when added
// to the baseline is the offset (+y is up). Our grid goes down. // to the baseline is the offset (+y is up). Our grid goes down.
// So we flip it with `cell_size.y - glyph_offset.y`. // So we flip it with `cell_size.y - glyph_offset.y`.
glyph_offset_calc.y = cell_size_scaled.y - glyph_offset_calc.y; glyph_offset_calc.y = -glyph_offset_calc.y;
// If this is a constrained mode, we need to constrain it! // If this is a constrained mode, we need to constrain it!
// We also always constrain colored glyphs since we should have // We also always constrain colored glyphs since we should have