Skip to content

Commit 7829394

Browse files
committed
_LoadFontImpl: params.fontConfig.FontDataOwnedByAtlas = true
Fix for an issue mentioned at ocornut/imgui@98636f4#r172496863 The issue is that fontData.data is freed immediately afterwards, but imgui/FreeType may still need to read the TTF buffer later (particularly with the new baked-font workflow). Before the commit, imgui always copied the buffer when FontDataOwnedByAtlas == false, which unintentionally masked this bug.
1 parent 902dd7d commit 7829394

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

src/hello_imgui/impl/hello_imgui_font.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,8 @@ namespace HelloImGui
110110
if (params.insideAssets)
111111
{
112112
AssetFileData fontData = LoadAssetFileData(fontFilename.c_str());
113-
params.fontConfig.FontDataOwnedByAtlas = false;
113+
params.fontConfig.FontDataOwnedByAtlas = true;
114114
font = ImGui::GetIO().Fonts->AddFontFromMemoryTTF(fontData.data, (int)fontData.dataSize, fontSize, &params.fontConfig);
115-
FreeAssetFileData(&fontData);
116115
}
117116
else
118117
{

0 commit comments

Comments
 (0)