mirror of
https://github.com/ocornut/imgui.git
synced 2024-11-23 21:09:01 +08:00
Fonts: added IMGUI_DISABLE_DEFAULT_FONT macro. (#8161)
This commit is contained in:
parent
eb0ad66d88
commit
5ae3dd52a0
@ -53,6 +53,8 @@ Other changes:
|
|||||||
|
|
||||||
- Error Handling: fixed cases where recoverable error handling would crash when
|
- Error Handling: fixed cases where recoverable error handling would crash when
|
||||||
processing errors outside of the NewFrame()..EndFrame() scope. (#1651)
|
processing errors outside of the NewFrame()..EndFrame() scope. (#1651)
|
||||||
|
- Misc: added IMGUI_DISABLE_DEFAULT_FONT to strip embedded font from binary. (#8161)
|
||||||
|
[@demonese]
|
||||||
- Demo: example tree used by Property Editor & Selection demos properly freed
|
- Demo: example tree used by Property Editor & Selection demos properly freed
|
||||||
on application closure. (#8158) [@Legulysse]
|
on application closure. (#8158) [@Legulysse]
|
||||||
- Examples: Win32+DX12: Using a basic free-list allocator to manage multiple
|
- Examples: Win32+DX12: Using a basic free-list allocator to manage multiple
|
||||||
|
@ -48,6 +48,7 @@
|
|||||||
//#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 font (ProggyClean.ttf), remove ~14 KB from output binary. AddFontDefault() 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.
|
||||||
|
@ -2560,7 +2560,9 @@ ImFont* ImFontAtlas::AddFont(const ImFontConfig* font_cfg)
|
|||||||
// Default font TTF is compressed with stb_compress then base85 encoded (see misc/fonts/binary_to_compressed_c.cpp for encoder)
|
// Default font TTF is compressed with stb_compress then base85 encoded (see misc/fonts/binary_to_compressed_c.cpp for encoder)
|
||||||
static unsigned int stb_decompress_length(const unsigned char* input);
|
static unsigned int stb_decompress_length(const unsigned char* input);
|
||||||
static unsigned int stb_decompress(unsigned char* output, const unsigned char* input, unsigned int length);
|
static unsigned int stb_decompress(unsigned char* output, const unsigned char* input, unsigned int length);
|
||||||
|
#ifndef IMGUI_DISABLE_DEFAULT_FONT
|
||||||
static const char* GetDefaultCompressedFontDataTTFBase85();
|
static const char* GetDefaultCompressedFontDataTTFBase85();
|
||||||
|
#endif
|
||||||
static unsigned int Decode85Byte(char c) { return c >= '\\' ? c-36 : c-35; }
|
static unsigned int Decode85Byte(char c) { return c >= '\\' ? c-36 : c-35; }
|
||||||
static void Decode85(const unsigned char* src, unsigned char* dst)
|
static void Decode85(const unsigned char* src, unsigned char* dst)
|
||||||
{
|
{
|
||||||
@ -2576,6 +2578,7 @@ static void Decode85(const unsigned char* src, unsigned char* dst)
|
|||||||
// Load embedded ProggyClean.ttf at size 13, disable oversampling
|
// Load embedded ProggyClean.ttf at size 13, disable oversampling
|
||||||
ImFont* ImFontAtlas::AddFontDefault(const ImFontConfig* font_cfg_template)
|
ImFont* ImFontAtlas::AddFontDefault(const ImFontConfig* font_cfg_template)
|
||||||
{
|
{
|
||||||
|
#ifndef IMGUI_DISABLE_DEFAULT_FONT
|
||||||
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)
|
||||||
{
|
{
|
||||||
@ -2593,6 +2596,11 @@ ImFont* ImFontAtlas::AddFontDefault(const ImFontConfig* font_cfg_template)
|
|||||||
const ImWchar* glyph_ranges = font_cfg.GlyphRanges != NULL ? font_cfg.GlyphRanges : GetGlyphRangesDefault();
|
const ImWchar* glyph_ranges = font_cfg.GlyphRanges != NULL ? font_cfg.GlyphRanges : GetGlyphRangesDefault();
|
||||||
ImFont* font = AddFontFromMemoryCompressedBase85TTF(ttf_compressed_base85, font_cfg.SizePixels, &font_cfg, glyph_ranges);
|
ImFont* font = AddFontFromMemoryCompressedBase85TTF(ttf_compressed_base85, font_cfg.SizePixels, &font_cfg, glyph_ranges);
|
||||||
return font;
|
return font;
|
||||||
|
#else
|
||||||
|
IM_ASSERT(0 && "AddFontDefault() disabled in this build.");
|
||||||
|
IM_UNUSED(font_cfg_template);
|
||||||
|
return NULL;
|
||||||
|
#endif // #ifndef IMGUI_DISABLE_DEFAULT_FONT
|
||||||
}
|
}
|
||||||
|
|
||||||
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)
|
||||||
@ -4578,6 +4586,8 @@ static unsigned int stb_decompress(unsigned char *output, const unsigned char *i
|
|||||||
// Exported using misc/fonts/binary_to_compressed_c.cpp (with compression + base85 string encoding).
|
// Exported using misc/fonts/binary_to_compressed_c.cpp (with compression + base85 string encoding).
|
||||||
// The purpose of encoding as base85 instead of "0x00,0x01,..." style is only save on _source code_ size.
|
// The purpose of encoding as base85 instead of "0x00,0x01,..." style is only save on _source code_ size.
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#ifndef IMGUI_DISABLE_DEFAULT_FONT
|
||||||
static const char proggy_clean_ttf_compressed_data_base85[11980 + 1] =
|
static const char proggy_clean_ttf_compressed_data_base85[11980 + 1] =
|
||||||
"7])#######hV0qs'/###[),##/l:$#Q6>##5[n42>c-TH`->>#/e>11NNV=Bv(*:.F?uu#(gRU.o0XGH`$vhLG1hxt9?W`#,5LsCp#-i>.r$<$6pD>Lb';9Crc6tgXmKVeU2cD4Eo3R/"
|
"7])#######hV0qs'/###[),##/l:$#Q6>##5[n42>c-TH`->>#/e>11NNV=Bv(*:.F?uu#(gRU.o0XGH`$vhLG1hxt9?W`#,5LsCp#-i>.r$<$6pD>Lb';9Crc6tgXmKVeU2cD4Eo3R/"
|
||||||
"2*>]b(MC;$jPfY.;h^`IWM9<Lh2TlS+f-s$o6Q<BWH`YiU.xfLq$N;$0iR/GX:U(jcW2p/W*q?-qmnUCI;jHSAiFWM.R*kU@C=GH?a9wp8f$e.-4^Qg1)Q-GL(lf(r/7GrRgwV%MS=C#"
|
"2*>]b(MC;$jPfY.;h^`IWM9<Lh2TlS+f-s$o6Q<BWH`YiU.xfLq$N;$0iR/GX:U(jcW2p/W*q?-qmnUCI;jHSAiFWM.R*kU@C=GH?a9wp8f$e.-4^Qg1)Q-GL(lf(r/7GrRgwV%MS=C#"
|
||||||
@ -4670,5 +4680,6 @@ static const char* GetDefaultCompressedFontDataTTFBase85()
|
|||||||
{
|
{
|
||||||
return proggy_clean_ttf_compressed_data_base85;
|
return proggy_clean_ttf_compressed_data_base85;
|
||||||
}
|
}
|
||||||
|
#endif // #ifndef IMGUI_DISABLE_DEFAULT_FONT
|
||||||
|
|
||||||
#endif // #ifndef IMGUI_DISABLE
|
#endif // #ifndef IMGUI_DISABLE
|
||||||
|
Loading…
Reference in New Issue
Block a user