imgui_freetype: add FreeType headers & compiled version number in the 'About Dear ImGui' user facing string.

This commit is contained in:
ocornut
2026-04-07 17:18:16 +02:00
parent 49df3116bc
commit 7cb0baeb77
2 changed files with 24 additions and 12 deletions
+2
View File
@@ -46,6 +46,8 @@ Other Changes:
- InputText: - InputText:
- InputTextMultiline: fixed an issue processing deactivation logic when an active - InputTextMultiline: fixed an issue processing deactivation logic when an active
multi-line edit is clipped due to being out of view. multi-line edit is clipped due to being out of view.
- Fonts:
- imgui_freetype: add FreeType headers & compiled version in 'About Dear ImGui' details.
- Backends: - Backends:
- Metal: avoid redundant vertex buffer bind in SetupRenderState, which leads - Metal: avoid redundant vertex buffer bind in SetupRenderState, which leads
to validation issue. (#9343) [@Hunam6] to validation issue. (#9343) [@Hunam6]
+22 -12
View File
@@ -95,6 +95,10 @@ static void* (*GImGuiFreeTypeAllocFunc)(size_t size, void* user_data) = ImGuiFre
static void (*GImGuiFreeTypeFreeFunc)(void* ptr, void* user_data) = ImGuiFreeTypeDefaultFreeFunc; static void (*GImGuiFreeTypeFreeFunc)(void* ptr, void* user_data) = ImGuiFreeTypeDefaultFreeFunc;
static void* GImGuiFreeTypeAllocatorUserData = nullptr; static void* GImGuiFreeTypeAllocatorUserData = nullptr;
// Load struct
static ImFontLoader GImGuiFreeTypeLoader;
static char GImGuiFreeTypeLoaderName[48] = "FreeType";
// Lunasvg support // Lunasvg support
#ifdef IMGUI_ENABLE_FREETYPE_LUNASVG #ifdef IMGUI_ENABLE_FREETYPE_LUNASVG
static FT_Error ImGuiLunasvgPortInit(FT_Pointer* state); static FT_Error ImGuiLunasvgPortInit(FT_Pointer* state);
@@ -146,6 +150,7 @@ struct ImGui_ImplFreeType_Data
{ {
FT_Library Library; FT_Library Library;
FT_MemoryRec_ MemoryManager; FT_MemoryRec_ MemoryManager;
char BackendName[48];
ImGui_ImplFreeType_Data() { memset((void*)this, 0, sizeof(*this)); } ImGui_ImplFreeType_Data() { memset((void*)this, 0, sizeof(*this)); }
}; };
@@ -359,6 +364,11 @@ static bool ImGui_ImplFreeType_LoaderInit(ImFontAtlas* atlas)
return false; return false;
} }
// Update ImFontLoader::Name field with linked version
FT_Int ver_linked_major, ver_linked_minor, ver_linked_patch;
FT_Library_Version(bd->Library, &ver_linked_major, &ver_linked_minor, &ver_linked_patch);
snprintf(GImGuiFreeTypeLoaderName, sizeof(GImGuiFreeTypeLoaderName), "FreeType (%d.%d.%d; %d.%d.%d)", FREETYPE_MAJOR, FREETYPE_MINOR, FREETYPE_PATCH, ver_linked_major, ver_linked_minor, ver_linked_patch);
// If you don't call FT_Add_Default_Modules() the rest of code may work, but FreeType won't use our custom allocator. // If you don't call FT_Add_Default_Modules() the rest of code may work, but FreeType won't use our custom allocator.
FT_Add_Default_Modules(bd->Library); FT_Add_Default_Modules(bd->Library);
@@ -569,18 +579,18 @@ static bool ImGui_ImplFreetype_FontSrcContainsGlyph(ImFontAtlas* atlas, ImFontCo
const ImFontLoader* ImGuiFreeType::GetFontLoader() const ImFontLoader* ImGuiFreeType::GetFontLoader()
{ {
static ImFontLoader loader; ImFontLoader* loader = &GImGuiFreeTypeLoader;
loader.Name = "FreeType"; loader->Name = GImGuiFreeTypeLoaderName; // Initially "FreeType" then updated during the call to ImGui_ImplFreeType_LoaderInit()
loader.LoaderInit = ImGui_ImplFreeType_LoaderInit; loader->LoaderInit = ImGui_ImplFreeType_LoaderInit;
loader.LoaderShutdown = ImGui_ImplFreeType_LoaderShutdown; loader->LoaderShutdown = ImGui_ImplFreeType_LoaderShutdown;
loader.FontSrcInit = ImGui_ImplFreeType_FontSrcInit; loader->FontSrcInit = ImGui_ImplFreeType_FontSrcInit;
loader.FontSrcDestroy = ImGui_ImplFreeType_FontSrcDestroy; loader->FontSrcDestroy = ImGui_ImplFreeType_FontSrcDestroy;
loader.FontSrcContainsGlyph = ImGui_ImplFreetype_FontSrcContainsGlyph; loader->FontSrcContainsGlyph = ImGui_ImplFreetype_FontSrcContainsGlyph;
loader.FontBakedInit = ImGui_ImplFreeType_FontBakedInit; loader->FontBakedInit = ImGui_ImplFreeType_FontBakedInit;
loader.FontBakedDestroy = ImGui_ImplFreeType_FontBakedDestroy; loader->FontBakedDestroy = ImGui_ImplFreeType_FontBakedDestroy;
loader.FontBakedLoadGlyph = ImGui_ImplFreeType_FontBakedLoadGlyph; loader->FontBakedLoadGlyph = ImGui_ImplFreeType_FontBakedLoadGlyph;
loader.FontBakedSrcLoaderDataSize = sizeof(ImGui_ImplFreeType_FontSrcBakedData); loader->FontBakedSrcLoaderDataSize = sizeof(ImGui_ImplFreeType_FontSrcBakedData);
return &loader; return loader;
} }
void ImGuiFreeType::SetAllocatorFunctions(void* (*alloc_func)(size_t sz, void* user_data), void (*free_func)(void* ptr, void* user_data), void* user_data) void ImGuiFreeType::SetAllocatorFunctions(void* (*alloc_func)(size_t sz, void* user_data), void (*free_func)(void* ptr, void* user_data), void* user_data)