thedmd / imgui-node-editor

Node Editor built using Dear ImGui
MIT License
3.47k stars 527 forks source link

SDF text rendering #261

Open crolando opened 8 months ago

crolando commented 8 months ago

Have you experimented with SDF text rendering? Or is there a way to make text more visible when the nodes are very small?

thedmd commented 8 months ago

To be clear I would have to say that all text rendering is done via ImGui. Node editor does not touch that.

Solution I'm using in our production code is to have two fonts with two different sizes. Now that I realized support for that was my unpublished change I made a PR which adds RasterizationDensity.

Back to solution I use. I generate two fonts, one with 100% scaling, one with 400% scalling. I pick default font based on how much canvas is zoomed in. When it is zoomed-in > 200% I use 400% font. Otherwise I use 100%.

Addressing your question directly: As an extra when view is zoomed out to avoid tons of small unreadable texts I fade them away. I think you can try to create small font with bosted RasterizationDensity to make it more readable. Trick would work to an extent, but at some point text became to small to be readable. This is leading to the solution with fading text away.

Does this help with your case?


Support for SDF fonts is possible and can be done. Node editor itself does not impose any limitation in that matter. When in scope of this project it would be the job of example application harness to support that.

crolando commented 7 months ago

That sounds good!

For my projects, I depend on your patched copy of imgui in your "external" folder, because that is also patched with the FringeScale feature. This might be a big ask, but can you patch the RasterizationDensity feature into your external\imgui code?

thedmd commented 6 months ago

external\imgui is oldes supported version if ImGui. Node Editor should work with your own copy of ImGui just fine. I'm perdodically fixing issues when they arise.

Did you know that official ImGui repository have FringeScale merged? : )

Backport of RasterizationDensity is possible, but probably not an no-op. ImGui cleaned up atlas generation code some time ago and I expect conflicts when trying to cherry-pick those changes.

BDW. RasterizationDensity is also merged on ImGui too.

You can pick latest ImGui and cherry-pick Stack Layout PR if you're using it.

Please let me know if that does work for you.