HexaEngine / Hexa.NET.ImGui.Widgets

MIT License
2 stars 0 forks source link

How to solve the problem of blurred Chinese fonts #1

Closed Charltsing closed 2 weeks ago

Charltsing commented 2 weeks ago

IMGUI.net sample 1

Hexa.NET.ImGui.Widgets demo 2

Maybe there is a way to make Chinese fonts not appear blurry at 16 pixels, but I haven't found it yet.

JunaMeinhold commented 2 weeks ago

You shouldn't used fixed (in this context) this will create a heap corruption, you either have to use the File load function or you have to keep the pointer alive for the time that the texture is created. And additionally read the Ownership comment, ImGui cannot free a piece of memory allocated with the GC either use mashal AllocH and Free or my utils.

JunaMeinhold commented 2 weeks ago

the pointer has to be alive until you call

ImGui.GetTexDataAsRGBA32(io.Fonts, &pixels, &width, &height, null);

and create a texture after that it's safe to free.

JunaMeinhold commented 2 weeks ago

if you want that imgui keeps ownership then i suggest using ImGui.MemAlloc instead of Marshal or my utils, this prevents issues with freeing.

JunaMeinhold commented 2 weeks ago

(font size 24) image (font size 16) image (font size 16 with config.PixelSnapH = true; config.OversampleH = 1;) image

the smaller you go, the more "blur" you get, and make sure you have your DPI configuration correct. (like in SDL2 or WinApi, or any windowing framework.)

Charltsing commented 2 weeks ago

It may be a problem with ImGui

Maybe there is a way to make Chinese fonts not appear blurry at 16 pixels, but I haven't found it yet.