Version/Branch of Dear ImGui:
v1.92.5
Back-ends:
Custom (PCSX2)
Compiler, OS:
macOS + Apple Clang 17
Full config/build information:
No response
Details:
While many latin fonts are just kilobytes, other fonts can get pretty big. CJK fonts are often a few megabytes, Noto Color Emoji is 25MB, and Apple Color Emoji (which doesn't work yet, but might in the future) is 150MB. With those kinds of sizes, it would be ideal to mmap the font to avoid loading the parts that don't get used, but at the very least you don't want multiple copies getting loaded even if you want to e.g. add an emoji font to the fallback path of multiple ImFonts.
ImGui currently has ImFontConfig::FontDataOwnedByAtlas to allow you to select whether ImGui manages the memory of the font so you just set that to false and...
|
if (font_cfg->FontDataOwnedByAtlas == false) |
|
{ |
|
font_cfg->FontDataOwnedByAtlas = true; |
|
font_cfg->FontData = ImMemdup(font_cfg->FontData, (size_t)font_cfg->FontDataSize); |
|
} |
Is there some other way to add a TTF to a font that trusts the caller to keep the memory alive until fonts are cleared/removed?
Screenshots/Video:
N/A unless you want a picture of my application's memory usage
Minimal, Complete and Verifiable Example code:
No response
Version/Branch of Dear ImGui:
v1.92.5
Back-ends:
Custom (PCSX2)
Compiler, OS:
macOS + Apple Clang 17
Full config/build information:
No response
Details:
While many latin fonts are just kilobytes, other fonts can get pretty big. CJK fonts are often a few megabytes, Noto Color Emoji is 25MB, and Apple Color Emoji (which doesn't work yet, but might in the future) is 150MB. With those kinds of sizes, it would be ideal to mmap the font to avoid loading the parts that don't get used, but at the very least you don't want multiple copies getting loaded even if you want to e.g. add an emoji font to the fallback path of multiple
ImFonts.ImGui currently has
ImFontConfig::FontDataOwnedByAtlasto allow you to select whether ImGui manages the memory of the font so you just set that to false and...imgui/imgui_draw.cpp
Lines 3055 to 3059 in 6d910d5
Is there some other way to add a TTF to a font that trusts the caller to keep the memory alive until fonts are cleared/removed?
Screenshots/Video:
N/A unless you want a picture of my application's memory usage
Minimal, Complete and Verifiable Example code:
No response