Im developing translation on little script that uses ImGui as frontend. I need extended set of unicode characters to be available in font that will be used. Since this script is injecting via DLL there's no way (I think so. I have no experience with c++ at all.) to use:
io.Fonts->AddFontFromFileTTF("myfontfile.ttf", size_in_pixels);
Adding font from ttf file resulted in error that data == NULL;
void* data = ImFileLoadToMemory(filename, "rb", &data_size, 0);
if (!data)
{
IM_ASSERT(0); // Could not load file.
return NULL;
}
I've also tried to use io.Fonts->AddFontFromMemoryCompressedBase85TTF and compiling font by included binary_to_compressed_c but output is so big that I'm getting:
fatal error C1091: compiler limit: string exceeds 65535 bytes in length
But function is not accepting any types except char*. I was connecting chars into string and then re-assemble it by str() and c_str() but app was crashing after injection. Here is function handling base85 conversion from ImGui:
ImFont* ImFontAtlas::AddFontFromMemoryCompressedBase85TTF(const char* compressed_ttf_data_base85, float size_pixels, const ImFontConfig* font_cfg, const ImWchar* glyph_ranges)
{
int compressed_ttf_size = (((int)strlen(compressed_ttf_data_base85) + 4) / 5) * 4;
void* compressed_ttf = ImGui::MemAlloc((size_t)compressed_ttf_size);
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;
}
How I can fix this problem ? I've tried everything and nothing is working. Only passing smaller chars into compile function is working (Tried with bundled Cousine_Regular.ttf).