debugFontAtlases
Parameters
- src:std.builtin.SourceLocation
- std.builtin.SourceLocation
- opts:Options
- Options
Source
Implementation
pub fn debugFontAtlases(src: std.builtin.SourceLocation, opts: Options) void {
const cw = currentWindow();
var width: u32 = 0;
var height: u32 = 0;
var it = cw.fonts.cache.iterator();
while (it.next()) |kv| {
const texture_atlas = kv.value_ptr.getTextureAtlas(cw.gpa, cw.backend) catch |err| {
dvui.logError(@src(), err, "Could not get texture atlast for '{s}' at height {d}", .{ kv.value_ptr.name, kv.value_ptr.height });
continue;
};
width = @max(width, texture_atlas.width);
height += texture_atlas.height;
}
const sizePhys: Size.Physical = .{ .w = @floatFromInt(width), .h = @floatFromInt(height) };
const ss = parentGet().screenRectScale(Rect{}).s;
const size = sizePhys.scale(1.0 / ss, Size);
var wd = WidgetData.init(src, .{}, opts.override(.{ .name = "debugFontAtlases", .min_size_content = size }));
wd.register();
wd.borderAndBackground(.{});
var rs = wd.parent.screenRectScale(placeIn(wd.contentRect(), size, .none, opts.gravityGet()));
const color = opts.color(.text);
it = cw.fonts.cache.iterator();
while (it.next()) |kv| {
const texture_atlas = kv.value_ptr.getTextureAtlas(cw.gpa, cw.backend) catch continue;
rs.r = rs.r.toSize(.{
.w = @floatFromInt(texture_atlas.width),
.h = @floatFromInt(texture_atlas.height),
});
renderTexture(texture_atlas, rs, .{ .colormod = color }) catch |err| {
logError(@src(), err, "Could not render font atlast for '{s}'", .{kv.value_ptr.name});
};
rs.r.y += rs.r.h;
}
wd.minSizeSetAndRefresh();
wd.minSizeReportToParent();
}