From f2bc722a582862f94a7ad4d3a4e658ba33b1de5b Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Wed, 31 Dec 2025 13:35:37 -0800 Subject: [PATCH] pkg/dcimgui: fix wchar size mismatch --- pkg/dcimgui/main.zig | 4 ++++ src/inspector/Inspector.zig | 36 ++++++++++++++++++------------------ 2 files changed, 22 insertions(+), 18 deletions(-) diff --git a/pkg/dcimgui/main.zig b/pkg/dcimgui/main.zig index 00a3c739d..e709158f5 100644 --- a/pkg/dcimgui/main.zig +++ b/pkg/dcimgui/main.zig @@ -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"); }); diff --git a/src/inspector/Inspector.zig b/src/inspector/Inspector.zig index 7029b7d3a..156e2cb18 100644 --- a/src/inspector/Inspector.zig +++ b/src/inspector/Inspector.zig @@ -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 {