ocornut / imgui

Dear ImGui: Bloat-free Graphical User interface for C++ with minimal dependencies
MIT License
59.97k stars 10.19k forks source link

Feature request: font ligature supporting #2572

Closed zeroxer closed 5 years ago

zeroxer commented 5 years ago

I want to use a font that designed for programming symbols, which can change two or more characters to one font character, as the following picture shows.

all_ligatures

FiraCode: Monospaced font with programming ligatures. Github: https://github.com/tonsky/FiraCode

Is there anyway to support this in ImGui ?

ocornut commented 5 years ago

Ligatures are not supported. In fact our whole text rendering pipeline is quite poor, mostly in order to make size calculation as fast as possible. If we were to support any better text rendering we should transition to a model where we can cache sizes and maybe text layout (separately).

TL;DR; Extremely unlikely in the mid term.

zeroxer commented 5 years ago

Thanks for your reply. Maybe I would try to implement it in the other way.

ratchetfreak commented 5 years ago

You can use the Private Use Area for font glyphs and do the replace of the multi-symbol markers with those unicode code points in the text rendering.

ocornut commented 5 years ago

I am going to close this as unsupported and not planned. As ratchetfreak pointed out, you may also use ImFont::AddRemapChar() after atlas building to redirect certain codepoint to others, and may get away with this as workaround depending on your use case.

zeroxer commented 5 years ago

Ok.Thanks. I think ImFont::AddRemapChar() is what I need.