From 69e6f299f32166a7557861b95e452bab8a16ecdf Mon Sep 17 00:00:00 2001 From: osman-brian Date: Thu, 1 Oct 2015 14:57:31 -0400 Subject: [PATCH 1/2] Update imgui_draw.cpp Fix Decode85 on big-endian systems. --- imgui_draw.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/imgui_draw.cpp b/imgui_draw.cpp index dcf30d9b..656d25e7 100644 --- a/imgui_draw.cpp +++ b/imgui_draw.cpp @@ -1079,7 +1079,17 @@ static unsigned int stb_decompress_length(unsigned char *input); static unsigned int stb_decompress(unsigned char *output, unsigned char *i, unsigned int length); static const char* GetDefaultCompressedFontDataTTFBase85(); static unsigned int Decode85Byte(char c) { return c >= '\\' ? c-36 : c-35; } -static void Decode85(const unsigned char* src, unsigned int* dst) { for (; *src; src += 5) *dst++ = Decode85Byte(src[0]) + 85*(Decode85Byte(src[1]) + 85*(Decode85Byte(src[2]) + 85*(Decode85Byte(src[3]) + 85*Decode85Byte(src[4])))); } +static void Decode85(const unsigned char* src, unsigned char* dst) +{ + for (; *src; src += 5) + { + unsigned int tmp = Decode85Byte(src[0]) + 85*(Decode85Byte(src[1]) + 85*(Decode85Byte(src[2]) + 85*(Decode85Byte(src[3]) + 85*Decode85Byte(src[4])))); + *dst++ = ((tmp >> 0) & 0xFF); + *dst++ = ((tmp >> 8) & 0xFF); + *dst++ = ((tmp >> 16) & 0xFF); + *dst++ = ((tmp >> 24) & 0xFF); + } +} // Load embedded ProggyClean.ttf at size 13, disable oversampling ImFont* ImFontAtlas::AddFontDefault(const ImFontConfig* font_cfg_template) @@ -1146,7 +1156,7 @@ ImFont* ImFontAtlas::AddFontFromMemoryCompressedBase85TTF(const char* compressed { int compressed_ttf_size = (((int)strlen(compressed_ttf_data_base85) + 4) / 5) * 4; void* compressed_ttf = ImGui::MemAlloc(compressed_ttf_size); - Decode85((const unsigned char*)compressed_ttf_data_base85, (unsigned int*)compressed_ttf); + Decode85((const unsigned char*)compressed_ttf_data_base85, (unsigned char*)compressed_ttf); ImFont* font = AddFontFromMemoryCompressedTTF(compressed_ttf, compressed_ttf_size, size_pixels, font_cfg, glyph_ranges); ImGui::MemFree(compressed_ttf); return font; From edf730b672b8b04fc3449a4a75d318c57999bdb3 Mon Sep 17 00:00:00 2001 From: ocornut Date: Thu, 8 Oct 2015 20:44:13 +0200 Subject: [PATCH 2/2] Missing tidying up (#358) --- imgui_draw.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/imgui_draw.cpp b/imgui_draw.cpp index 656d25e7..e91ba390 100644 --- a/imgui_draw.cpp +++ b/imgui_draw.cpp @@ -1081,13 +1081,12 @@ static const char* GetDefaultCompressedFontDataTTFBase85(); static unsigned int Decode85Byte(char c) { return c >= '\\' ? c-36 : c-35; } static void Decode85(const unsigned char* src, unsigned char* dst) { - for (; *src; src += 5) + while (*src) { unsigned int tmp = Decode85Byte(src[0]) + 85*(Decode85Byte(src[1]) + 85*(Decode85Byte(src[2]) + 85*(Decode85Byte(src[3]) + 85*Decode85Byte(src[4])))); - *dst++ = ((tmp >> 0) & 0xFF); - *dst++ = ((tmp >> 8) & 0xFF); - *dst++ = ((tmp >> 16) & 0xFF); - *dst++ = ((tmp >> 24) & 0xFF); + dst[0] = ((tmp >> 0) & 0xFF); dst[1] = ((tmp >> 8) & 0xFF); dst[2] = ((tmp >> 16) & 0xFF); dst[3] = ((tmp >> 24) & 0xFF); // We can't assume little-endianess. + src += 5; + dst += 4; } }