Skip to content

Commit

Permalink
dep/imgui: Don't copy the font data on building
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
stenzek committed Aug 25, 2024
1 parent 6deb2eb commit 44471a6
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions dep/imgui/src/imgui_draw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 44471a6

Please sign in to comment.