mirror of
https://github.com/Drezil/imgui.git
synced 2024-12-18 06:06:35 +00:00
Merge remote-tracking branch 'origin' into 2015-05-menus
This commit is contained in:
commit
03720acaff
18
imgui.cpp
18
imgui.cpp
@ -8648,8 +8648,8 @@ ImFont* ImFontAtlas::AddFontFromFileTTF(const char* filename, float size_pixels,
|
|||||||
return font;
|
return font;
|
||||||
}
|
}
|
||||||
|
|
||||||
// NB: ownership of 'data' is given to ImFontAtlas which will clear it.
|
// Transfer ownership of 'ttf_data' to ImFontAtlas, will be deleted after Build()
|
||||||
ImFont* ImFontAtlas::AddFontFromMemoryTTF(void* in_ttf_data, unsigned int in_ttf_data_size, float size_pixels, const ImWchar* glyph_ranges, int font_no)
|
ImFont* ImFontAtlas::AddFontFromMemoryTTF(void* ttf_data, int ttf_size, float size_pixels, const ImWchar* glyph_ranges, int font_no)
|
||||||
{
|
{
|
||||||
// Create new font
|
// Create new font
|
||||||
ImFont* font = (ImFont*)ImGui::MemAlloc(sizeof(ImFont));
|
ImFont* font = (ImFont*)ImGui::MemAlloc(sizeof(ImFont));
|
||||||
@ -8660,8 +8660,8 @@ ImFont* ImFontAtlas::AddFontFromMemoryTTF(void* in_ttf_data, unsigned int in_ttf
|
|||||||
ImFontAtlasData* data = (ImFontAtlasData*)ImGui::MemAlloc(sizeof(ImFontAtlasData));
|
ImFontAtlasData* data = (ImFontAtlasData*)ImGui::MemAlloc(sizeof(ImFontAtlasData));
|
||||||
memset(data, 0, sizeof(ImFontAtlasData));
|
memset(data, 0, sizeof(ImFontAtlasData));
|
||||||
data->OutFont = font;
|
data->OutFont = font;
|
||||||
data->TTFData = in_ttf_data;
|
data->TTFData = ttf_data;
|
||||||
data->TTFDataSize = in_ttf_data_size;
|
data->TTFDataSize = (size_t)ttf_size;
|
||||||
data->SizePixels = size_pixels;
|
data->SizePixels = size_pixels;
|
||||||
data->GlyphRanges = glyph_ranges;
|
data->GlyphRanges = glyph_ranges;
|
||||||
data->FontNo = font_no;
|
data->FontNo = font_no;
|
||||||
@ -8673,15 +8673,15 @@ ImFont* ImFontAtlas::AddFontFromMemoryTTF(void* in_ttf_data, unsigned int in_ttf
|
|||||||
return font;
|
return font;
|
||||||
}
|
}
|
||||||
|
|
||||||
ImFont* ImFontAtlas::AddFontFromMemoryCompressedTTF(const void* in_compressed_ttf_data, unsigned int in_compressed_ttf_data_size, float size_pixels, const ImWchar* glyph_ranges, int font_no)
|
ImFont* ImFontAtlas::AddFontFromMemoryCompressedTTF(const void* compressed_ttf_data, int compressed_ttf_size, float size_pixels, const ImWchar* glyph_ranges, int font_no)
|
||||||
{
|
{
|
||||||
// Decompress
|
// Decompress
|
||||||
const size_t buf_decompressed_size = stb_decompress_length((unsigned char*)in_compressed_ttf_data);
|
const size_t buf_decompressed_size = stb_decompress_length((unsigned char*)compressed_ttf_data);
|
||||||
unsigned char* buf_decompressed = (unsigned char *)ImGui::MemAlloc(buf_decompressed_size);
|
unsigned char* buf_decompressed_data = (unsigned char *)ImGui::MemAlloc(buf_decompressed_size);
|
||||||
stb_decompress(buf_decompressed, (unsigned char*)in_compressed_ttf_data, in_compressed_ttf_data_size);
|
stb_decompress(buf_decompressed_data, (unsigned char*)compressed_ttf_data, (unsigned int)compressed_ttf_size);
|
||||||
|
|
||||||
// Add
|
// Add
|
||||||
ImFont* font = AddFontFromMemoryTTF(buf_decompressed, (unsigned int)buf_decompressed_size, size_pixels, glyph_ranges, font_no);
|
ImFont* font = AddFontFromMemoryTTF(buf_decompressed_data, (int)buf_decompressed_size, size_pixels, glyph_ranges, font_no);
|
||||||
return font;
|
return font;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
4
imgui.h
4
imgui.h
@ -974,8 +974,8 @@ struct ImFontAtlas
|
|||||||
IMGUI_API ~ImFontAtlas();
|
IMGUI_API ~ImFontAtlas();
|
||||||
IMGUI_API ImFont* AddFontDefault();
|
IMGUI_API ImFont* AddFontDefault();
|
||||||
IMGUI_API ImFont* AddFontFromFileTTF(const char* filename, float size_pixels, const ImWchar* glyph_ranges = NULL, int font_no = 0);
|
IMGUI_API ImFont* AddFontFromFileTTF(const char* filename, float size_pixels, const ImWchar* glyph_ranges = NULL, int font_no = 0);
|
||||||
IMGUI_API ImFont* AddFontFromMemoryTTF(void* in_ttf_data, unsigned int in_ttf_data_size, float size_pixels, const ImWchar* glyph_ranges = NULL, int font_no = 0); // Pass ownership of 'in_ttf_data' memory, will be deleted after build
|
IMGUI_API ImFont* AddFontFromMemoryTTF(void* ttf_data, int ttf_size, float size_pixels, const ImWchar* glyph_ranges = NULL, int font_no = 0); // Transfer ownership of 'ttf_data' to ImFontAtlas, will be deleted after Build()
|
||||||
IMGUI_API ImFont* AddFontFromMemoryCompressedTTF(const void* in_compressed_ttf_data, unsigned int in_compressed_ttf_data_size, float size_pixels, const ImWchar* glyph_ranges = NULL, int font_no = 0); // 'in_compressed_ttf_data' untouched and still owned by caller. compress with binary_to_compressed_c.
|
IMGUI_API ImFont* AddFontFromMemoryCompressedTTF(const void* compressed_ttf_data, int compressed_ttf_size, float size_pixels, const ImWchar* glyph_ranges = NULL, int font_no = 0); // 'compressed_ttf_data' untouched and still owned by caller. Compress with binary_to_compressed_c.cpp
|
||||||
IMGUI_API void ClearTexData(); // Saves RAM once the texture has been copied to graphics memory.
|
IMGUI_API void ClearTexData(); // Saves RAM once the texture has been copied to graphics memory.
|
||||||
IMGUI_API void Clear();
|
IMGUI_API void Clear();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user