Skip to content

Commit

Permalink
修复部分情况下字体渲染卡顿
Browse files Browse the repository at this point in the history
  • Loading branch information
chinosk6 committed Dec 21, 2023
1 parent 01a478d commit ea6428a
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/hook.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,8 @@ namespace
void* (*TMP_FontAsset_CreateFontAsset)(void* font);
void (*TMP_Text_set_font)(void* _this, void* fontAsset);
void* (*TMP_Text_get_font)(void* _this);
void* lastUpdateFontPtr = nullptr;
// void* lastUpdateFontPtr = nullptr;
std::unordered_set<void*> updatedFontPtrs{};

void* UITextMeshProUGUI_Awake_orig;
void UITextMeshProUGUI_Awake_hook(void* _this) {
Expand Down Expand Up @@ -453,10 +454,15 @@ namespace
if (replaceFont) {
auto origFont = TMP_Text_get_font(_this);
set_sourceFontFile(origFont, replaceFont);
if (!updatedFontPtrs.contains(origFont)) {
updatedFontPtrs.emplace(origFont);
UpdateFontAssetData(origFont);
}
/*
if (origFont != lastUpdateFontPtr) {
UpdateFontAssetData(origFont);
lastUpdateFontPtr = origFont;
}
}*/
}
reinterpret_cast<decltype(UITextMeshProUGUI_Awake_hook)*>(UITextMeshProUGUI_Awake_orig)(_this);
}
Expand Down

0 comments on commit ea6428a

Please sign in to comment.