Fonts: added IMGUI_DISABLE_STB_TRUETYPE. (#9573)

This commit is contained in:
ocornut 2026-10-05 19:41:20 +02:00
parent 68bd43b2b4
commit 4989b4c754
4 changed files with 7 additions and 2 deletions

View File

@ -94,6 +94,8 @@ Other Changes:
- (Internal) ImFontLoader: reworked `FontSrcContainsGlyph`, `FontBakedLoadGlyph` signatures - (Internal) ImFontLoader: reworked `FontSrcContainsGlyph`, `FontBakedLoadGlyph` signatures
to take raw glyph index instead of codepoint. Added `FontSrcGetGlyphIndexFromCodepoint`. to take raw glyph index instead of codepoint. Added `FontSrcGetGlyphIndexFromCodepoint`.
(#9559, #5647, #9540, #8466, #8465) (#9559, #5647, #9540, #8466, #8465)
- Added `IMGUI_DISABLE_STB_TRUETYPE` to completely omit the stb_truetype loader
code + stb_truetype.h code. (#9573)
- ColorEdit: - ColorEdit:
- ColorButton, ColorEdit, ColorPicker: cancel-out alpha caused by BeginDisabled() so - ColorButton, ColorEdit, ColorPicker: cancel-out alpha caused by BeginDisabled() so
disabled color buttons have the same color as non-disabled oness. (#9511) disabled color buttons have the same color as non-disabled oness. (#9511)

View File

@ -72,7 +72,8 @@
//---- Use 32-bit for ImWchar (default is 16-bit) to support Unicode planes 1-16. (e.g. point beyond 0xFFFF like emoticons, dingbats, symbols, shapes, ancient languages, etc...) //---- Use 32-bit for ImWchar (default is 16-bit) to support Unicode planes 1-16. (e.g. point beyond 0xFFFF like emoticons, dingbats, symbols, shapes, ancient languages, etc...)
//#define IMGUI_USE_WCHAR32 //#define IMGUI_USE_WCHAR32
//---- Avoid multiple STB libraries implementations, or redefine path/filenames to prioritize another version //---- Avoid multiple STB libraries implementations, or redefine path/filenames to prioritize another version.
// This is for if you already embed a copy of those library in your code and don't want duplicate code in your binary.
// By default the embedded implementations are declared static and not available outside of Dear ImGui sources files. // By default the embedded implementations are declared static and not available outside of Dear ImGui sources files.
//#define IMGUI_STB_TRUETYPE_FILENAME "my_folder/stb_truetype.h" //#define IMGUI_STB_TRUETYPE_FILENAME "my_folder/stb_truetype.h"
//#define IMGUI_STB_RECT_PACK_FILENAME "my_folder/stb_rect_pack.h" //#define IMGUI_STB_RECT_PACK_FILENAME "my_folder/stb_rect_pack.h"
@ -102,6 +103,7 @@
//---- Use stb_truetype to build and rasterize the font atlas (default) //---- Use stb_truetype to build and rasterize the font atlas (default)
// The only purpose of this define is if you want force compilation of the stb_truetype backend ALONG with the FreeType backend. // The only purpose of this define is if you want force compilation of the stb_truetype backend ALONG with the FreeType backend.
//#define IMGUI_ENABLE_STB_TRUETYPE //#define IMGUI_ENABLE_STB_TRUETYPE
//#define IMGUI_DISABLE_STB_TRUETYPE
//---- Define constructor and implicit cast operators to convert back<>forth between your math types and ImVec2/ImVec4. //---- Define constructor and implicit cast operators to convert back<>forth between your math types and ImVec2/ImVec4.
// This will be inlined as part of ImVec2 and ImVec4 class declarations. // This will be inlined as part of ImVec2 and ImVec4 class declarations.

View File

@ -16741,6 +16741,7 @@ void ImGui::ShowFontAtlas(ImFontAtlas* atlas)
if (TreeNode("Loader", "Loader: \'%s\'", atlas->FontLoaderName ? atlas->FontLoaderName : "NULL")) if (TreeNode("Loader", "Loader: \'%s\'", atlas->FontLoaderName ? atlas->FontLoaderName : "NULL"))
{ {
const ImFontLoader* loader_current = atlas->FontLoader; const ImFontLoader* loader_current = atlas->FontLoader;
IM_UNUSED(loader_current);
BeginDisabled(!atlas->RendererHasTextures); BeginDisabled(!atlas->RendererHasTextures);
#ifdef IMGUI_ENABLE_STB_TRUETYPE #ifdef IMGUI_ENABLE_STB_TRUETYPE
const ImFontLoader* loader_stbtruetype = ImFontAtlasGetFontLoaderForStbTruetype(); const ImFontLoader* loader_stbtruetype = ImFontAtlasGetFontLoaderForStbTruetype();

View File

@ -126,7 +126,7 @@ Index of this file:
// Enable stb_truetype by default unless FreeType is enabled. // 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. // You can compile with both by defining both IMGUI_ENABLE_FREETYPE and IMGUI_ENABLE_STB_TRUETYPE together.
#ifndef IMGUI_ENABLE_FREETYPE #if !defined(IMGUI_ENABLE_FREETYPE) && !defined(IMGUI_ENABLE_STB_TRUETYPE) && !defined(IMGUI_DISABLE_STB_TRUETYPE)
#define IMGUI_ENABLE_STB_TRUETYPE #define IMGUI_ENABLE_STB_TRUETYPE
#endif #endif