dep/imgui: Don't copy the font data on building

For the CJK and SVG fonts, this is a **considerable** memory allocation
and copy, up to 20MB+. We really don't want to be doing this
unnecessarily, since we keep the buffer around anyway.
This commit is contained in:
Stenzek 2024-08-26 00:25:35 +10:00
parent a9342195d3
commit 323c297fed
No known key found for this signature in database
1 changed files with 3 additions and 0 deletions

View File

@ -2504,12 +2504,15 @@ ImFont* ImFontAtlas::AddFont(const ImFontConfig* font_cfg)
ImFontConfig& new_font_cfg = ConfigData.back();
if (new_font_cfg.DstFont == NULL)
new_font_cfg.DstFont = Fonts.back();
#if 0
// DUCKSTATION-CHANGE: We maintain the allocations ourselves. Saves copying 14MB or so.
if (!new_font_cfg.FontDataOwnedByAtlas)
{
new_font_cfg.FontData = IM_ALLOC(new_font_cfg.FontDataSize);
new_font_cfg.FontDataOwnedByAtlas = true;
memcpy(new_font_cfg.FontData, font_cfg->FontData, (size_t)new_font_cfg.FontDataSize);
}
#endif
if (new_font_cfg.DstFont->EllipsisChar == (ImWchar)-1)
new_font_cfg.DstFont->EllipsisChar = font_cfg->EllipsisChar;