ImGui.NET icon indicating copy to clipboard operation
ImGui.NET copied to clipboard

add Font then use with ImGui.PushFont case 'System.AccessViolationException'.

Open CorrM opened this issue 5 years ago • 3 comments

how i add Font

// create the object on the native side and wrap it in a C# class
            ImFontConfig* nativeConfig = ImGuiNative.ImFontConfig_ImFontConfig();
            var config = new ImFontConfigPtr(nativeConfig)
            {
                OversampleH = 2,
                OversampleV = 1,
                RasterizerMultiply = 1f,
                MergeMode = true
            };

            ImGui.GetIO().Fonts.AddFontDefault();
            _textFont = ImGui.GetIO().Fonts.AddFontFromFileTTF(@"C:\Windows\Fonts\Arial.ttf", 20f, nativeConfig);

            // delete the reference. ImGui copies it
            config.Destroy();

when i use

ImGui.PushFont(_textFont); // Here Error
drawer.AddText(new Vector2(50f, 50f), 0, $"pCount");
ImGui.PopFont();
System.AccessViolationException: 'Attempted to read or write protected memory. This is often an indication that other memory is corrupt.'

CorrM avatar Nov 14 '19 17:11 CorrM

Same problem here as well

oxysoft avatar Nov 16 '19 08:11 oxysoft

https://github.com/mellinoe/ImGui.NET/issues/125#issuecomment-554942927 https://github.com/mellinoe/ImGui.NET/issues/132#issuecomment-525093161 https://github.com/mellinoe/ImGui.NET/issues/133#issuecomment-529652438

sonoro1234 avatar Nov 20 '19 11:11 sonoro1234

Did you solve it? I am currently facing the same problem

abo-nb avatar May 05 '24 08:05 abo-nb