Closed MetalDeveloper closed 8 months ago
Font changing isn’t easy in this lib, sometime code is better than 1000 words so use this as reference: https://github.com/zaafar/ClickableTransparentOverlay/blob/master/Examples/SingleThreadedOverlayWithCoroutines/SampleOverlay.cs#L116
I tried that but I get this error when I run it.
Here is my code (My goal is to make a watermark that is displayed on the screen):
if (drawWatermark) { ImGui.SetNextWindowSize(screenSize); ImGui.SetNextWindowPos(new Vector2(0, 0)); ImGui.Begin("Overlay", ImGuiWindowFlags.NoDecoration | ImGuiWindowFlags.NoBackground | ImGuiWindowFlags.NoBringToFrontOnFocus | ImGuiWindowFlags.NoMove | ImGuiWindowFlags.NoInputs | ImGuiWindowFlags.NoCollapse | ImGuiWindowFlags.NoScrollbar | ImGuiWindowFlags.NoScrollWithMouse );
ImDrawListPtr drawList = ImGui.GetWindowDrawList();
if ((DateTime.Now - _lastTime).TotalSeconds >= 2.25)
{
// one second has elapsed
_fps = _framesRendered;
_framesRendered = 0;
_lastTime = DateTime.Now;
}
this.ReplaceFont(@"C:\Windows\Fonts\msyh.ttc", 23, FontGlyphRangeType.English);
font2 = null;
//drawList.AddRectFilled(new Vector2(2, 5), new Vector2(120, 45), ImGui.ColorConvertFloat4ToU32(new Vector4(0.08f, 0.08f, 0.085f, 1f)), 6f);
drawList.AddText(watermarkPos, ImGui.ColorConvertFloat4ToU32(new Vector4(1f, 1f, 1f, 1f)), "MetalWare");
drawList.AddText(fpsPos, ImGui.ColorConvertFloat4ToU32(new Vector4(1f, 1f, 1f, 1f)), "FPS: " + _fps);
if (font2 != null)
{
ImGui.PushFont(font2.Value);
}
Make sure you are using the latest version of imgui.net. We fixed this bug few months ago.
I was using an outdated version, im testing it rn.
i get this error when i updated to the latest release (im using .net 6.0)
Only works for me without crashing
You don’t need vsync feature of that library, just remove that if condition.
I removed that line and i get that (thats not my code thats the actual im gui .net code)
i also get this with it
Do you have a discord? Can I add you on their and you can help me easily?
How can I reproduce this issue on my side? For this purpose, I am wondering if u can give me the changes required to reproduce the issue in the sample projects (e.g. https://github.com/ImGuiNET/ImGui.NET/tree/master/src/ImGui.NET.SampleProgram OR https://github.com/zaafar/ClickableTransparentOverlay/tree/master/Examples)
Can I just send you a simple project that does the same thing?
Can I add you on discord so you can help me easier?
my discord is: metal_developer
💀 you helped me then just said good luck when it created a problem
i fixed it
I knew you would be able to fix it yourself, good stuff! Closing the issue.
how did you fix it? i cannot for the life of me get fonts working
Hello,
Recently while making something I came across something were I wanted to change the font, in the process I have came up with an idea of how to do it but for some reason it will not change the font and stays the default font. I don't know if this is an issue on my end or the program itself. I am trying to render text onto the screen. Here is my code to do so.
void DrawOverlay() {
{ ImGui.SetNextWindowSize(screenSize); ImGui.SetNextWindowPos(new Vector2(0, 0)); ImGui.Begin("Overlay", ImGuiWindowFlags.NoDecoration | ImGuiWindowFlags.NoBackground | ImGuiWindowFlags.NoBringToFrontOnFocus | ImGuiWindowFlags.NoMove | ImGuiWindowFlags.NoInputs | ImGuiWindowFlags.NoCollapse | ImGuiWindowFlags.NoScrollbar | ImGuiWindowFlags.NoScrollWithMouse );
}
Please help me fix this if I am doing something wrong on my end. Also yes, the custom ttf file is in the correct directory.