Open zmdyy0318 opened 7 months ago
You must provide ImFontConfig struct to AddFontFromFileTTF function while it's MergeMode set to true. Like this
ImFontConfig merge_config = {};
merge_config.MergeMode = true;
static const ImWchar rangesFixed[] = {
0x0020, 0x00FF, // Basic Latin + Latin Supplement
0x2026, 0x2026, // ellipsis
0
};
static const ImWchar rangesIcons[] = {
ICON_MIN_FA, ICON_MAX_FA,
0
};
io.Fonts->AddFontFromFileTTF("c:\\Windows\\Fonts\\Consola.ttf", 16, NULL, rangesFixed);
io.Fonts->AddFontFromMemoryCompressedTTF(FontAwesomeSolid_compressed_data, FontAwesomeSolid_compressed_size, 16, &merge_config, rangesIcons);
It shouldn't matter where your glyph ranges are coming from.
Version/Branch of Dear ImGui:
Version 1.90.1
Back-ends:
imgui_impl_opengl3.cpp
Compiler, OS:
windows 11
Details:
i need use dynamic loading character range to accelerate the font texture loading, for draw diff font text
first, load font1 font2 font3:
ImFontGlyphRangesBuilder builder1; builder1.AddText("qwert"); auto font1 = io.Fonts->AddFontFromFileTTF("font1.ttc", 40, nullptr, builder1.Data);
ImFontGlyphRangesBuilder builder2; builder2.AddText("asdfg"); auto font2 = io.Fonts->AddFontFromFileTTF("font2.ttc", 40, nullptr, builder2.Data);
ImFontGlyphRangesBuilder builder3; builder3.AddText("zxcvb"); auto font3 = io.Fonts->AddFontFromFileTTF("font3.ttc", 40, nullptr, builder3.Data);
so, how to merge "poiuy" text to font2: ImFontConfig.MergeMode only can merge to last font(font3), how to merge to font1 or font2