Disabling stb_freetype... doesn't actually disable it. #9573

Closed
opened 2026-10-05 17:29:33 +00:00 by VeraDev0 · 0 comments
VeraDev0 commented 2026-10-05 17:29:33 +00:00 (Migrated from github.com)

Version/Branch of Dear ImGui:

Version 1.XX, Branch: XXX (master/docking/etc.)

Back-ends:

imgui_impl_XXX.cpp + imgui_impl_XXX.cpp

Compiler, OS:

Windows 11 + MSVC (VS2026)

Full config/build information:

Unneeded

Details:

If you ever wanted to use your own FontLoader for ImGui, you will probably hit this issue where ImGui will try using stb freetype or freetype no matter what.

What i mean is IMGUI_DISABLE_STB_TRUETYPE_IMPLEMENTATION will get completely ignored if u don't define IMGUI_ENABLE_FREETYPE
ocornut/imgui@68bd43b2b4/imgui_internal.h (L127-L131)

So you are forced to modify the ImGui source code just so it doesn't do that which cleary isn't ideal.

I usually replace that snippet of code with this. Perhaps this is the solution? (I'm quite unsure if this is good or not)

// Enable stb_truetype by default unless FreeType is enabled.
// You can compile with both by defining both IMGUI_ENABLE_FREETYPE and IMGUI_ENABLE_STB_TRUETYPE together.
// NOTE: Defining IMGUI_DISABLE_STB_TRUETYPE_IMPLEMENTATION will override the other two and forcefully disable stb_truetype implementation.
#if !defined(IMGUI_ENABLE_FREETYPE) && !defined(IMGUI_ENABLE_STB_TRUETYPE) && !defined(IMGUI_DISABLE_STB_TRUETYPE_IMPLEMENTATION)
#define IMGUI_ENABLE_STB_TRUETYPE
#endif

Screenshots/Video:

Image

Minimal, Complete and Verifiable Example code:

imconfig.h

#define IMGUI_DISABLE_STB_TRUETYPE_IMPLEMENTATION 
// Do not define IMGUI_ENABLE_STD_TRUETYPE. Look in the imgui_internal.h and
//  find "#ifndef IMGUI_ENABLE_FREETYPE". You can see its still enabled even with this define.
### Version/Branch of Dear ImGui: Version 1.XX, Branch: XXX (master/docking/etc.) ### Back-ends: imgui_impl_XXX.cpp + imgui_impl_XXX.cpp ### Compiler, OS: Windows 11 + MSVC (VS2026) ### Full config/build information: Unneeded ### Details: If you ever wanted to use your own FontLoader for ImGui, you will probably hit this issue where ImGui will try using stb freetype or freetype no matter what. What i mean is `IMGUI_DISABLE_STB_TRUETYPE_IMPLEMENTATION` will get completely ignored if u don't define `IMGUI_ENABLE_FREETYPE` https://github.com/ocornut/imgui/blob/68bd43b2b455168571f99794132df136cc45329e/imgui_internal.h#L127-L131 So you are forced to modify the ImGui source code just so it doesn't do that which cleary isn't ideal. I usually replace that snippet of code with this. Perhaps this is the solution? (I'm quite unsure if this is good or not) ```cpp // Enable stb_truetype by default unless FreeType is enabled. // You can compile with both by defining both IMGUI_ENABLE_FREETYPE and IMGUI_ENABLE_STB_TRUETYPE together. // NOTE: Defining IMGUI_DISABLE_STB_TRUETYPE_IMPLEMENTATION will override the other two and forcefully disable stb_truetype implementation. #if !defined(IMGUI_ENABLE_FREETYPE) && !defined(IMGUI_ENABLE_STB_TRUETYPE) && !defined(IMGUI_DISABLE_STB_TRUETYPE_IMPLEMENTATION) #define IMGUI_ENABLE_STB_TRUETYPE #endif ``` ### Screenshots/Video: <img width="1027" height="581" alt="Image" src="https://github.com/user-attachments/assets/4ab88ab4-45be-47ba-a44e-a64c336d76a9" /> ### Minimal, Complete and Verifiable Example code: imconfig.h ```cpp #define IMGUI_DISABLE_STB_TRUETYPE_IMPLEMENTATION // Do not define IMGUI_ENABLE_STD_TRUETYPE. Look in the imgui_internal.h and // find "#ifndef IMGUI_ENABLE_FREETYPE". You can see its still enabled even with this define. ```
Sign in to join this conversation.
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
ocornut/imgui#9573
No description provided.