no clue man

This commit is contained in:
Vicente Ferrari Smith 2026-01-16 00:28:30 +01:00
parent 52ea7dcfa5
commit 61b2dd0417
2 changed files with 35 additions and 20 deletions

View File

@ -75,8 +75,6 @@ pub const Font = struct {
try face.loadGlyph(@intCast(i), .{}); try face.loadGlyph(@intCast(i), .{});
const bmp = face.glyph().bitmap(); const bmp = face.glyph().bitmap();
std.log.info("got size {}, {}", .{bmp.width(), bmp.rows()});
try rects.append(allocator, .{ try rects.append(allocator, .{
.id = @intCast(face.glyph().glyphIndex()), .id = @intCast(face.glyph().glyphIndex()),
.w = @intCast(bmp.width()), .w = @intCast(bmp.width()),
@ -193,7 +191,15 @@ pub const Font = struct {
return; return;
if (nice_background) { if (nice_background) {
self.render_text(text, pos.add(.{.x = 3.0, .y = -3.0}), window_space, rl.Color.init(0, 0, 0, 255), rl.Color.init(0, 0, 0, 0), false, false); self.render_text(
text,
pos.add(.{.x = 3.0, .y = -3.0}),
window_space,
rl.Color.init(0, 0, 0, 255),
rl.Color.init(0, 0, 0, 0),
false,
false
);
} }
var render_pos = pos; var render_pos = pos;
@ -237,14 +243,17 @@ pub const Font = struct {
// glyph : *Glyph = table_find_pointer(*text.font.glyphs, RunGlyph.Id); // glyph : *Glyph = table_find_pointer(*text.font.glyphs, RunGlyph.Id);
if (self.glyphs.getPtr(RunGlyph.Id)) |glyph| { if (self.glyphs.getPtr(RunGlyph.Id)) |glyph| {
std.log.info("glyph: {}", .{glyph});
var v0 = rl.Vector2.zero(); var v0 = rl.Vector2.zero();
var v1 = rl.Vector2.zero(); var v1 = rl.Vector2.zero();
if (count_descent) { if (count_descent) {
v0 = render_pos.add(.{ .x = x_offset,// + glyph.bearing_x, v0 = render_pos.add(.{ .x = x_offset,// + glyph.bearing_x,
.y = y_offset - @as(f32, @floatFromInt(glyph.bearing_y)) + draw_size.y });// /*- max_descent*/}; .y = y_offset - @as(f32, @floatFromInt(glyph.bearing_y)) + draw_size.y });// /*- max_descent*/};
} else { } else {
v0 = render_pos.add(.{ .x = x_offset,// + glyph.bearing_x, v0 = render_pos.add(.{
.y = y_offset - @as(f32, @floatFromInt(@as(i32, @intCast(glyph.height)) - glyph.bearing_y)) });//* - glyph.height + draw_size.y*/}; .x = x_offset,// + glyph.bearing_x,
.y = y_offset - @as(f32, @floatFromInt(@as(i32, @intCast(glyph.height)) - glyph.bearing_y))
});//* - glyph.height + draw_size.y*/};
} }
v1 = v0.add(rl.Vector2{ .x = @floatFromInt(glyph.width), .y = @floatFromInt(glyph.height) }); v1 = v0.add(rl.Vector2{ .x = @floatFromInt(glyph.width), .y = @floatFromInt(glyph.height) });
@ -254,8 +263,14 @@ pub const Font = struct {
y_offset += @floatFromInt(ft.mulFix(RunGlyph.AdvanceY, @intCast(self.face.size().metrics().y_scale)) >> 6); y_offset += @floatFromInt(ft.mulFix(RunGlyph.AdvanceY, @intCast(self.face.size().metrics().y_scale)) >> 6);
// #if Y_IS_UP { // #if Y_IS_UP {
// t0 := Vector2.{cast(float, glyph.x) / cast(float, ATLAS_SIZE), cast(float, glyph.y) / cast(float, ATLAS_SIZE)}; // t0 := Vector2.{
// t1 := t0 + Vector2.{cast(float, glyph.width) / cast(float, ATLAS_SIZE), -cast(float, glyph.height) / cast(float, ATLAS_SIZE)}; // cast(float, glyph.x) / cast(float, ATLAS_SIZE),
// cast(float, glyph.y) / cast(float, ATLAS_SIZE)
// };
// t1 := t0 + Vector2.{
// cast(float, glyph.width) / cast(float, ATLAS_SIZE),
// -cast(float, glyph.height) / cast(float, ATLAS_SIZE)
// };
const st0 = glyph.st0; const st0 = glyph.st0;
const st1 = glyph.st1; const st1 = glyph.st1;
// } else { // } else {

View File

@ -180,22 +180,22 @@ pub fn main() !void {
rl.beginDrawing(); rl.beginDrawing();
f.texture.drawPro( // f.texture.drawPro(
.{.x = 0, .y = 0, .width = 4096, .height = 4096}, // .{.x = 0, .y = 0, .width = 4096, .height = 4096},
.{.x = 0, .y = 0, .width = 512, .height = 512 }, // .{.x = 0, .y = 0, .width = 512, .height = 512 },
.zero(), 0, .white); // .zero(), 0, .white);
rl.beginShaderMode(shader); rl.beginShaderMode(shader);
// f.render_text( f.render_text(
// "H", "H",
// rl.Vector2.init(400, 400), rl.Vector2.init(400, 400),
// true, true,
// rl.Color.white, rl.Color.white,
// rl.Color.blank, rl.Color.blank,
// true, true,
// true true
// ); );
// rl.gl.rlBegin(rl.gl.rl_triangles); // rl.gl.rlBegin(rl.gl.rl_triangles);