pkg/dcimgui: fix wchar size mismatch

This commit is contained in:
Mitchell Hashimoto
2025-12-31 13:35:37 -08:00
parent 965ffb1750
commit f2bc722a58
2 changed files with 22 additions and 18 deletions

View File

@@ -1,6 +1,10 @@
pub const build_options = @import("build_options");
pub const c = @cImport({
// This is set during the build so it also has to be set
// during import time to get the right types. Without this
// you get stack size mismatches on some structs.
@cDefine("IMGUI_USE_WCHAR32", "1");
@cInclude("dcimgui.h");
});

View File

@@ -138,24 +138,24 @@ pub fn setup() void {
io.IniFilename = null;
io.LogFilename = null;
// // Use our own embedded font
// {
// // TODO: This will have to be recalculated for different screen DPIs.
// // This is currently hardcoded to a 2x content scale.
// const font_size = 16 * 2;
//
// var font_config: cimgui.c.ImFontConfig = .{};
// cimgui.ext.ImFontConfig_ImFontConfig(&font_config);
// font_config.FontDataOwnedByAtlas = false;
// _ = cimgui.c.ImFontAtlas_AddFontFromMemoryTTF(
// io.Fonts,
// @ptrCast(@constCast(font.embedded.regular.ptr)),
// @intCast(font.embedded.regular.len),
// font_size,
// &font_config,
// null,
// );
// }
// Use our own embedded font
{
// TODO: This will have to be recalculated for different screen DPIs.
// This is currently hardcoded to a 2x content scale.
const font_size = 16 * 2;
var font_config: cimgui.c.ImFontConfig = undefined;
cimgui.ext.ImFontConfig_ImFontConfig(&font_config);
font_config.FontDataOwnedByAtlas = false;
_ = cimgui.c.ImFontAtlas_AddFontFromMemoryTTF(
io.Fonts,
@ptrCast(@constCast(font.embedded.regular.ptr)),
@intCast(font.embedded.regular.len),
font_size,
&font_config,
null,
);
}
}
pub fn init(surface: *Surface) !Inspector {