mirror of
https://github.com/ocornut/imgui.git
synced 2024-11-27 16:29:02 +08:00
ImFontAtlas: allow AddFontDefault to take a config
This commit is contained in:
parent
7ad4843f57
commit
3e3d9f9a69
15
imgui.cpp
15
imgui.cpp
@ -9798,15 +9798,20 @@ static unsigned int stb_decompress_length(unsigned char *input);
|
||||
static unsigned int stb_decompress(unsigned char *output, unsigned char *i, unsigned int length);
|
||||
|
||||
// Load embedded ProggyClean.ttf at size 13
|
||||
ImFont* ImFontAtlas::AddFontDefault()
|
||||
ImFont* ImFontAtlas::AddFontDefault(const ImFontConfig* font_cfg_template)
|
||||
{
|
||||
unsigned int ttf_compressed_size;
|
||||
const void* ttf_compressed;
|
||||
GetDefaultCompressedFontDataTTF(&ttf_compressed, &ttf_compressed_size);
|
||||
ImFontConfig font_cfg;
|
||||
font_cfg.OversampleH = font_cfg.OversampleV = 1;
|
||||
font_cfg.PixelSnapH = true;
|
||||
strcpy(font_cfg.Name, "<default>");
|
||||
if (font_cfg_template)
|
||||
font_cfg = *font_cfg_template;
|
||||
else
|
||||
{
|
||||
font_cfg.OversampleH = font_cfg.OversampleV = 1;
|
||||
font_cfg.PixelSnapH = true;
|
||||
}
|
||||
if (font_cfg.Name[0] == '\0') strcpy(font_cfg.Name, "<default>");
|
||||
return AddFontFromMemoryCompressedTTF(ttf_compressed, ttf_compressed_size, 13.0f, &font_cfg, GetGlyphRangesDefault());
|
||||
}
|
||||
|
||||
@ -9820,7 +9825,7 @@ ImFont* ImFontAtlas::AddFontFromFileTTF(const char* filename, float size_pixels,
|
||||
return NULL;
|
||||
}
|
||||
ImFontConfig font_cfg = font_cfg_template ? *font_cfg_template : ImFontConfig();
|
||||
if (font_cfg.Name[0] == 0)
|
||||
if (font_cfg.Name[0] == '\0')
|
||||
{
|
||||
const char* p;
|
||||
for (p = filename + strlen(filename); p > filename && p[-1] != '/' && p[-1] != '\\'; p--) {}
|
||||
|
2
imgui.h
2
imgui.h
@ -1149,7 +1149,7 @@ struct ImFontAtlas
|
||||
IMGUI_API ImFontAtlas();
|
||||
IMGUI_API ~ImFontAtlas();
|
||||
IMGUI_API ImFont* AddFont(const ImFontConfig* font_cfg);
|
||||
IMGUI_API ImFont* AddFontDefault();
|
||||
IMGUI_API ImFont* AddFontDefault(const ImFontConfig* font_cfg = NULL);
|
||||
IMGUI_API ImFont* AddFontFromFileTTF(const char* filename, float size_pixels, const ImFontConfig* font_cfg = NULL, const ImWchar* glyph_ranges = NULL);
|
||||
IMGUI_API ImFont* AddFontFromMemoryTTF(void* ttf_data, int ttf_size, float size_pixels, const ImFontConfig* font_cfg = NULL, const ImWchar* glyph_ranges = NULL); // Transfer ownership of 'ttf_data' to ImFontAtlas, will be deleted after Build()
|
||||
IMGUI_API ImFont* AddFontFromMemoryCompressedTTF(const void* compressed_ttf_data, int compressed_ttf_size, float size_pixels, const ImFontConfig* font_cfg = NULL, const ImWchar* glyph_ranges = NULL); // 'compressed_ttf_data' untouched and still owned by caller. Compress with binary_to_compressed_c.cpp
|
||||
|
Loading…
Reference in New Issue
Block a user