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

AddFontFromFileTTF + GetGlyphRangesChineseFull does not work?

Open Charltsing opened this issue 2 years ago • 7 comments

ImGui.NET.SampleProgram, i add some code:

ImGuiIOPtr ioptr = ImGui.GetIO(); ioptr.Fonts.AddFontFromFileTTF("c:\Windows\Fonts\ArialUni.ttf", 18.0f, null, ioptr.Fonts.GetGlyphRangesChineseFull());

string text = "中文abc"; //chinese text ImGui.Text(text);

it does not work, why? it display --> ??abc


i use dear imgui-master :

io.Fonts->AddFontFromFileTTF("c:\Windows\Fonts\ArialUni.ttf", 18.0f, NULL, io.Fonts->GetGlyphRangesChineseFull()); ImGui::Text(u8"中文abc");

it works well.

Charltsing avatar Nov 25 '21 23:11 Charltsing

It works fine in my project. For example implementation try looking at this line: https://github.com/zaafar/ClickableTransparentOverlay/blob/master/Examples/SingleThreadedOverlayWithCoroutines/SampleOverlay.cs#L88

zaafar avatar Nov 26 '21 00:11 zaafar

It works fine in my project. For example implementation try looking at this line: https://github.com/zaafar/ClickableTransparentOverlay/blob/master/Examples/SingleThreadedOverlayWithCoroutines/SampleOverlay.cs#L88

it does not work in ImGui.NET.SampleProgram

i dont know where insert code ---> io.Fonts.AddFontFromFileTTF...

Charltsing avatar Nov 26 '21 15:11 Charltsing

Yeah SampleProgram isn’t updated to support this feature but that’s fine because it’s just a Sample Program. However, this is a supported feature of ImGui.NET library and can be used by the users of ImGui library as demonstrated in the URL I shared.

zaafar avatar Nov 26 '21 15:11 zaafar

Yeah SampleProgram isn’t updated to support this feature but that’s fine because it’s just a Sample Program. However, this is a supported feature of ImGui.NET library and can be used by the users of ImGui library as demonstrated in the URL I shared.

大哥,你那代码我实在看不下去。而且,调用Fonts.clear之后,Sample的代码会花屏。不调用它,你的代码就不工作。 Could you please add Chinese support to the official Sample?

Charltsing avatar Dec 05 '21 01:12 Charltsing

Could you please add Chinese support to the official Sample?

what’s the benefit? I have already shared with you an example that works.

zaafar avatar Dec 05 '21 01:12 zaafar

Make sure Font.Clear happens after ‘ _gd.SwapBuffers(_gd.MainSwapchain);’ function call. Remember, you can not change fonts while they are being used.

also, look at my https://github.com/zaafar/ClickableTransparentOverlay/blob/master/ClickableTransparentOverlay/ImGuiController.cs file. I changed it. The one in sample program is broken.

zaafar avatar Dec 05 '21 01:12 zaafar

In ImGui.NET.SampleProgram,you should remove the code: //ImGui.GetIO().Fonts.AddFontDefault();

also,you could choose the font in style editor: Snipaste_2021-12-28_16-08-30

it works well.

LonerDo avatar Dec 28 '21 08:12 LonerDo