zaafar / ClickableTransparentOverlay

A library for creating transparent overlay using windows API & ImGui.NET
Apache License 2.0
97 stars 32 forks source link

ReplaceFont raises a MissingMethodException exception (NuGet, >=ImGuiNET 1.89.5.1) #48

Closed accountrev closed 1 year ago

accountrev commented 1 year ago

When trying to use ReplaceFont in my program, it raises a System.MissingMethodException exception every time the function is ran. I tried the SingleThreadedOverlayWithCoroutines example as well, and it still raises this exception:

Unhandled exception. System.MissingMethodException: Method not found: 'ImGuiNET.ImFontPtr ImGuiNET.ImFontAtlasPtr.AddFontFromFileTTF(System.String, Single, ImGuiNET.ImFontConfigPtr, IntPtr)'.
   at ClickableTransparentOverlay.ImGuiRenderer.UpdateFontTexture(String fontPathName, Single fontSize, UInt16[] fontCustomGlyphRange, FontGlyphRangeType fontLanguage)
   at ClickableTransparentOverlay.Overlay.ReplaceFontIfRequired()
   at ClickableTransparentOverlay.Overlay.RunInfiniteLoop(CancellationToken token)
   at ClickableTransparentOverlay.Overlay.<Start>b__26_0()
   at System.Threading.Tasks.Task.<>c.<ThrowAsync>b__128_1(Object state)
   at System.Threading.ThreadPoolWorkQueue.Dispatch()
   at System.Threading.PortableThreadPool.WorkerThread.WorkerThreadStart()

I made sure ImGui.NET and the other dependencies are installed, and I don't know any workarounds for the time being.

zaafar commented 1 year ago

I will look into it. Thx for reporting.

NustyFrozen commented 1 year ago

^ same happens to me, although only through the nuget package if i download the src directly and add it to my project it works fine

NustyFrozen commented 1 year ago

i found a fix in the meantime, use an older version of imgui.net as the exception says, in the newer versions there is no overload method that takes (string string,uint16[],FontGlyphRangeType )

accountrev commented 1 year ago

use an older version of imgui.net

Can confirm, every ImGui.NET update after 1.89.5 does not work, due to the fact that ImGuiNET.ImFontAtlasPtr.AddFontFromFileTTF now uses ReadOnlySpan<char> instead of string for the filename argument. I also tried using CTO from source and it works perfectly fine, but I'm sticking to nuget for now so I'll use an older version until it's fixed.