Fonts: Added macros to disable ProggyClean/ProggyVector separately. (#9407)

This commit is contained in:
qwer
2026-05-27 16:50:53 +02:00
committed by ocornut
parent 243097ca8f
commit ac07da2b5b
3 changed files with 18 additions and 9 deletions
+3
View File
@@ -52,6 +52,9 @@ Other Changes:
- InputText: - InputText:
- Added style.InputTextCursorSize to configure cursor/caret thickness. (#7031, #9409) - Added style.InputTextCursorSize to configure cursor/caret thickness. (#7031, #9409)
This is automatically scaled by style.ScaleAllSizes(). This is automatically scaled by style.ScaleAllSizes().
- Fonts:
- Added `IMGUI_DISABLE_DEFAULT_FONT_BITMAP`/`IMGUI_DISABLE_DEFAULT_FONT_VECTOR` to
disable embedding either fonts separately. (#9407)
- Demo: - Demo:
- Extract 'Widgets->Tree Nodes->Selectable Nodes' out of the 'Advanced' - Extract 'Widgets->Tree Nodes->Selectable Nodes' out of the 'Advanced'
demo for clarity (manual reimplementation of basic selection). demo for clarity (manual reimplementation of basic selection).
+3 -1
View File
@@ -49,7 +49,9 @@
//#define IMGUI_DISABLE_FILE_FUNCTIONS // Don't implement ImFileOpen/ImFileClose/ImFileRead/ImFileWrite and ImFileHandle at all (replace them with dummies) //#define IMGUI_DISABLE_FILE_FUNCTIONS // Don't implement ImFileOpen/ImFileClose/ImFileRead/ImFileWrite and ImFileHandle at all (replace them with dummies)
//#define IMGUI_DISABLE_DEFAULT_FILE_FUNCTIONS // Don't implement ImFileOpen/ImFileClose/ImFileRead/ImFileWrite and ImFileHandle so you can implement them yourself if you don't want to link with fopen/fclose/fread/fwrite. This will also disable the LogToTTY() function. //#define IMGUI_DISABLE_DEFAULT_FILE_FUNCTIONS // Don't implement ImFileOpen/ImFileClose/ImFileRead/ImFileWrite and ImFileHandle so you can implement them yourself if you don't want to link with fopen/fclose/fread/fwrite. This will also disable the LogToTTY() function.
//#define IMGUI_DISABLE_DEFAULT_ALLOCATORS // Don't implement default allocators calling malloc()/free() to avoid linking with them. You will need to call ImGui::SetAllocatorFunctions(). //#define IMGUI_DISABLE_DEFAULT_ALLOCATORS // Don't implement default allocators calling malloc()/free() to avoid linking with them. You will need to call ImGui::SetAllocatorFunctions().
//#define IMGUI_DISABLE_DEFAULT_FONT // Disable default embedded fonts (ProggyClean/ProggyForever), remove ~9 KB + ~14 KB from output binary. AddFontDefaultXXX() functions will assert. //#define IMGUI_DISABLE_DEFAULT_FONT // Disable default embedded fonts (ProggyClean + ProggyForever). Remove ~9 KB + ~14 KB from output binary. AddFontDefaultXXX() functions will assert.
//#define IMGUI_DISABLE_DEFAULT_FONT_BITMAP // Disable default embedded bitmap font (ProggyClean). Remove ~9 KB from output binary. AddFontDefaultBitmap() will assert.
//#define IMGUI_DISABLE_DEFAULT_FONT_VECTOR // Disable default embedded vector font (ProggyForever), Remove ~14 KB from output binary. AddFontDefaultVector() will assert.
//#define IMGUI_DISABLE_SSE // Disable use of SSE intrinsics even if available //#define IMGUI_DISABLE_SSE // Disable use of SSE intrinsics even if available
//---- Enable Test Engine / Automation features. //---- Enable Test Engine / Automation features.
+12 -8
View File
@@ -3149,8 +3149,10 @@ static void Decode85(const unsigned char* src, unsigned char* dst)
dst += 4; dst += 4;
} }
} }
#ifndef IMGUI_DISABLE_DEFAULT_FONT #if !defined(IMGUI_DISABLE_DEFAULT_FONT) && !defined(IMGUI_DISABLE_DEFAULT_FONT_BITMAP)
static const char* GetDefaultCompressedFontDataProggyClean(int* out_size); static const char* GetDefaultCompressedFontDataProggyClean(int* out_size);
#endif
#if !defined(IMGUI_DISABLE_DEFAULT_FONT) && !defined(IMGUI_DISABLE_DEFAULT_FONT_VECTOR)
static const char* GetDefaultCompressedFontDataProggyForever(int* out_size); static const char* GetDefaultCompressedFontDataProggyForever(int* out_size);
#endif #endif
@@ -3175,7 +3177,7 @@ ImFont* ImFontAtlas::AddFontDefault(const ImFontConfig* font_cfg)
// If you want a similar font which may be better scaled, consider using AddFontDefaultVector(). // If you want a similar font which may be better scaled, consider using AddFontDefaultVector().
ImFont* ImFontAtlas::AddFontDefaultBitmap(const ImFontConfig* font_cfg_template) ImFont* ImFontAtlas::AddFontDefaultBitmap(const ImFontConfig* font_cfg_template)
{ {
#ifndef IMGUI_DISABLE_DEFAULT_FONT #if !defined(IMGUI_DISABLE_DEFAULT_FONT) && !defined(IMGUI_DISABLE_DEFAULT_FONT_BITMAP)
ImFontConfig font_cfg = font_cfg_template ? *font_cfg_template : ImFontConfig(); ImFontConfig font_cfg = font_cfg_template ? *font_cfg_template : ImFontConfig();
if (!font_cfg_template) if (!font_cfg_template)
font_cfg.PixelSnapH = true; // Prevents sub-integer scaling factors at lower-level layers. font_cfg.PixelSnapH = true; // Prevents sub-integer scaling factors at lower-level layers.
@@ -3196,14 +3198,14 @@ ImFont* ImFontAtlas::AddFontDefaultBitmap(const ImFontConfig* font_cfg_template)
IM_ASSERT(0 && "Function is disabled in this build."); IM_ASSERT(0 && "Function is disabled in this build.");
IM_UNUSED(font_cfg_template); IM_UNUSED(font_cfg_template);
return NULL; return NULL;
#endif // #ifndef IMGUI_DISABLE_DEFAULT_FONT #endif
} }
// Load a minimal version of ProggyForever, designed to match our good old ProggyClean, but nicely scalable. // Load a minimal version of ProggyForever, designed to match our good old ProggyClean, but nicely scalable.
// (See build script in https://github.com/ocornut/proggyforever for details) // (See build script in https://github.com/ocornut/proggyforever for details)
ImFont* ImFontAtlas::AddFontDefaultVector(const ImFontConfig* font_cfg_template) ImFont* ImFontAtlas::AddFontDefaultVector(const ImFontConfig* font_cfg_template)
{ {
#ifndef IMGUI_DISABLE_DEFAULT_FONT #if !defined(IMGUI_DISABLE_DEFAULT_FONT) && !defined(IMGUI_DISABLE_DEFAULT_FONT_VECTOR)
ImFontConfig font_cfg = font_cfg_template ? *font_cfg_template : ImFontConfig(); ImFontConfig font_cfg = font_cfg_template ? *font_cfg_template : ImFontConfig();
if (!font_cfg_template) if (!font_cfg_template)
font_cfg.PixelSnapH = true; // Precisely match ProggyClean, but prevents sub-integer scaling factors at lower-level layers. font_cfg.PixelSnapH = true; // Precisely match ProggyClean, but prevents sub-integer scaling factors at lower-level layers.
@@ -3224,7 +3226,7 @@ ImFont* ImFontAtlas::AddFontDefaultVector(const ImFontConfig* font_cfg_template)
IM_ASSERT(0 && "Function is disabled in this build."); IM_ASSERT(0 && "Function is disabled in this build.");
IM_UNUSED(font_cfg_template); IM_UNUSED(font_cfg_template);
return NULL; return NULL;
#endif // #ifndef IMGUI_DISABLE_DEFAULT_FONT #endif
} }
ImFont* ImFontAtlas::AddFontFromFileTTF(const char* filename, float size_pixels, const ImFontConfig* font_cfg_template, const ImWchar* glyph_ranges) ImFont* ImFontAtlas::AddFontFromFileTTF(const char* filename, float size_pixels, const ImFontConfig* font_cfg_template, const ImWchar* glyph_ranges)
@@ -6340,7 +6342,7 @@ static unsigned int stb_decompress(unsigned char *output, const unsigned char *i
// Download and more information at https://github.com/bluescan/proggyfonts // Download and more information at https://github.com/bluescan/proggyfonts
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
#ifndef IMGUI_DISABLE_DEFAULT_FONT #if !defined(IMGUI_DISABLE_DEFAULT_FONT) && !defined(IMGUI_DISABLE_DEFAULT_FONT_BITMAP)
// File: 'ProggyClean.ttf' (41208 bytes) // File: 'ProggyClean.ttf' (41208 bytes)
// Exported using binary_to_compressed_c.exe -u8 "ProggyClean.ttf" proggy_clean_ttf // Exported using binary_to_compressed_c.exe -u8 "ProggyClean.ttf" proggy_clean_ttf
@@ -6520,6 +6522,7 @@ static const char* GetDefaultCompressedFontDataProggyClean(int* out_size)
*out_size = proggy_clean_ttf_compressed_size; *out_size = proggy_clean_ttf_compressed_size;
return (const char*)proggy_clean_ttf_compressed_data; return (const char*)proggy_clean_ttf_compressed_data;
} }
#endif // #if !defined(IMGUI_DISABLE_DEFAULT_FONT) && !defined(IMGUI_DISABLE_DEFAULT_FONT_BITMAP)
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// [SECTION] Default font data (ProggyForever-Regular-minimal.ttf) // [SECTION] Default font data (ProggyForever-Regular-minimal.ttf)
@@ -6528,6 +6531,8 @@ static const char* GetDefaultCompressedFontDataProggyClean(int* out_size)
// MIT license / Copyright (c) 2026 Disco Hello, Copyright (c) 2019,2023 Tristan Grimmer // MIT license / Copyright (c) 2026 Disco Hello, Copyright (c) 2019,2023 Tristan Grimmer
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
#if !defined(IMGUI_DISABLE_DEFAULT_FONT) && !defined(IMGUI_DISABLE_DEFAULT_FONT_VECTOR)
// File: 'output/ProggyForever-Regular-minimal.ttf' (18556 bytes) // File: 'output/ProggyForever-Regular-minimal.ttf' (18556 bytes)
// Exported using binary_to_compressed_c.exe -u8 "output/ProggyForever-Regular-minimal.ttf" proggy_forever_minimal_ttf // Exported using binary_to_compressed_c.exe -u8 "output/ProggyForever-Regular-minimal.ttf" proggy_forever_minimal_ttf
static const unsigned int proggy_forever_minimal_ttf_compressed_size = 14562; static const unsigned int proggy_forever_minimal_ttf_compressed_size = 14562;
@@ -6782,7 +6787,6 @@ static const char* GetDefaultCompressedFontDataProggyForever(int* out_size)
*out_size = proggy_forever_minimal_ttf_compressed_size; *out_size = proggy_forever_minimal_ttf_compressed_size;
return (const char*)proggy_forever_minimal_ttf_compressed_data; return (const char*)proggy_forever_minimal_ttf_compressed_data;
} }
#endif // #if !defined(IMGUI_DISABLE_DEFAULT_FONT) && !defined(IMGUI_DISABLE_DEFAULT_FONT_VECTOR)
#endif // #ifndef IMGUI_DISABLE_DEFAULT_FONT
#endif // #ifndef IMGUI_DISABLE #endif // #ifndef IMGUI_DISABLE