This commit is contained in:
Vicente Ferrari Smith 2026-01-22 00:07:26 +01:00
parent 3f4280ae37
commit 063b46cec4

View File

@ -95,8 +95,8 @@ pub const Font = struct {
try rects.append(allocator, .{ try rects.append(allocator, .{
.id = @intCast(index),//@intCast(face.glyph().glyphIndex()), .id = @intCast(index),//@intCast(face.glyph().glyphIndex()),
.w = @intCast(bmp.width()), .w = @max(1, @as(c_int, @intCast(bmp.width()))),
.h = @intCast(bmp.rows()), .h = @max(1, @as(c_int, @intCast(bmp.rows()))),
.x = 0, .x = 0,
.y = 0, .y = 0,
.was_packed = 0, .was_packed = 0,
@ -111,7 +111,6 @@ pub const Font = struct {
try face.loadGlyph(index, .{ .render = true }); try face.loadGlyph(index, .{ .render = true });
const bmp = face.glyph().bitmap(); const bmp = face.glyph().bitmap();
const buf = bmp.buffer() orelse continue;
const pitch: usize = @intCast(bmp.pitch()); const pitch: usize = @intCast(bmp.pitch());
const w: usize = @intCast(bmp.width()); const w: usize = @intCast(bmp.width());
@ -120,6 +119,7 @@ pub const Font = struct {
const dst_x: usize = @intCast(rect.x); const dst_x: usize = @intCast(rect.x);
const dst_y: usize = @intCast(rect.y); const dst_y: usize = @intCast(rect.y);
if (bmp.buffer()) |buf| {
for (0..h) |y| { for (0..h) |y| {
const src = buf[y * pitch .. y * pitch + w]; const src = buf[y * pitch .. y * pitch + w];
@ -128,6 +128,7 @@ pub const Font = struct {
@memcpy(dst, src); @memcpy(dst, src);
} }
}
// std.log.info("{}", .{bmp.width()}); // std.log.info("{}", .{bmp.width()});
const width : i32 = @intCast(bmp.width()); const width : i32 = @intCast(bmp.width());
@ -374,7 +375,8 @@ pub const Font = struct {
// rl.gl.rlTexCoord2f(st1.x, st1.y); rl.gl.rlVertex2f(p1.x, p1.y); // rl.gl.rlTexCoord2f(st1.x, st1.y); rl.gl.rlVertex2f(p1.x, p1.y);
// rl.gl.rlTexCoord2f(st1.x, st0.y); rl.gl.rlVertex2f(p1.x, p0.y); // rl.gl.rlTexCoord2f(st1.x, st0.y); rl.gl.rlVertex2f(p1.x, p0.y);
} else { } else {
std.log.warn("kb_text_shape found the glyph, but we didn't load it from the font.", .{}); std.log.warn("kb_text_shape found the glyph, but we didn't load it from the font. index {}", .{RunGlyph.Id});
std.log.warn("advance_x {}", .{advance_x});
x_offset += dpi_advance_x; x_offset += dpi_advance_x;
y_offset += dpi_advance_y; y_offset += dpi_advance_y;
continue; continue;