fix y_offset

This commit is contained in:
Gabriel Dinner-David
2024-11-22 17:11:25 -05:00
parent f0fd846679
commit 7640e459e7
3 changed files with 6 additions and 6 deletions

View File

@ -57,7 +57,7 @@ fetch(url.href)
};
// Create our config
const config_str = makeStr("font-family = monospace");
const config_str = makeStr("font-family = monospace\nfont-size 32\n");
old(results);
run(config_str.ptr, config_str.len);
})

View File

@ -419,7 +419,7 @@ pub const Face = struct {
// Get the width and height of the render
const metrics_2 = try measure_ctx.call(js.Object, "measureText", .{glyph_str});
const top_desc = try metrics_2.get(f32, "actualBoundingBoxDescent") + 1;
const y_offset = @as(i32, @intFromFloat(top_desc)) - @as(i32, @intCast(height));
const y_offset = @as(i32, @intCast(height)) - @as(i32, @intFromFloat(top_desc));
ctx_temp.deinit();
// Note: width and height both get "+ 1" added to them above. This

View File

@ -32,6 +32,8 @@ fn run_(str: []const u8) !void {
var iter = cli.args.lineIterator(fbs.reader());
try cli.args.parse(Config, alloc, &config, &iter);
try config.finalize();
std.log.err("font-size {}", .{config.@"font-size"});
config.@"font-size" = 32;
const app = try App.create(alloc);
// Create our runtime app
var app_runtime = try apprt.App.init(app, .{});
@ -40,10 +42,8 @@ fn run_(str: []const u8) !void {
try surface.init(alloc, &config, app, &app_runtime, apprt_surface);
std.log.err("{}", .{surface.size});
try surface.renderer.setScreenSize(surface.size);
try surface.renderer_state.terminal.printString(
\\M_hello
);
surface.renderer_state.terminal.setCursorPos(2, 2);
try surface.renderer_state.terminal.printString("M_yhelloaaaaaaaaa\n🐏\n👍🏽\nM_ghostty");
surface.renderer_state.terminal.setCursorPos(4, 2);
try surface.renderer_state.terminal.setAttribute(.{ .direct_color_bg = .{
.r = 240,
.g = 40,